Skip to content
redactsure
Book a demo

Explore.

Data Report · RedactSure Research
Chris Sowa · Founder, RedactSure
Published
Last updated

How Do You Use Vault With a Coding Agent Without Exposing VAULT_TOKEN?

Put a service between the agent and Vault: the agent asks for an action, the service holds VAULT_TOKEN and the credential it fetches, and the agent gets the result. Check whether your tool has that service or exports the token into the agent's environment, as HashiCorp's tutorial does.

A credential reference travels from a browser record through a bounded route to a separate API destination.

A coding agent that needs a database password, a deploy key or a pull request has to get it somewhere, and the shortest documented path is HashiCorp's tutorial: issue the agent a Vault token, export it, and let the agent fetch what it needs. That path works, and it leaves the bearer credential inside the process that runs the model, where a command that prints an environment can carry it into the context. Within its policy a Vault token reads the path it was scoped to, and the scope belongs to the token, not the process holding it.

The alternative is architectural. A service outside the agent's sandbox holds the token, performs the call the agent asks for and hands back the result, so the context carries a pull request number, not the credential. Vault documents most of the pieces in response wrapping and leases, and no piece alone keeps the token out of the process that runs the model. The design therefore combines parts Vault documents with parts an organization writes, and it stops at one case: a token displayed on a page the agent reads.

Key findings

  • For a coding agent to use Vault without holding VAULT_TOKEN, the token would have to sit in a component the agent cannot read, and every value it unlocks would have to reach an approved destination rather than the model's context (What Is Least Exposure?).
  • It would also require a named person approving each call that releases a real credential, and a record of what the agent asked for beside what was released (RedactSure vs HashiCorp Vault: 2026 Comparison & Alternative).
  • HashiCorp's tutorial describes no component that holds the token while the agent works: its wrapper script "obtains a short-lived delegated RAR token, exports it as VAULT_TOKEN, and launches the agent," which places the value in the agent's environment (HashiCorp, Secure agent permissions, 2026).
  • The tutorial bounds the exposure by scope rather than custody: "the agent receives a token that is read-only, repo-only, scoped to a single secret, and short-lived," and "Token lifetime is reduced from days or weeks to minutes" (HashiCorp, Secure agent permissions, 2026).
  • HashiCorp's response wrapping page describes a delivery token, not a broker: "A new single-use token is generated with the TTL supplied by the client," and "Vault currently does not provide signed response-wrapping tokens" (HashiCorp, Response Wrapping, 2026).

What does the agent receive when a wrapper exports VAULT_TOKEN?

The tutorial's flow is worth following, because each step is reasonable and the last decides the answer. A wrapper script "obtains a short-lived delegated RAR token," exports it as VAULT_TOKEN before launching the agent, and the agent then reads the path the token allows (HashiCorp, Secure agent permissions, 2026). By then the token is a value in the process running the model. The placement is the documented default across the coding agents: in all 6 that the review scores, the credentials a team gives an agent are placed in environment variables the agent can read, while 2 of the 4 sandboxes keep them out by default, and Vault is not one of the ten (Can AI Coding Agents Read Your API Keys?).

A process is not a boundary. A model does not read the environment; the tools it drives do, and what a tool prints returns as text. A build that dumps its environment into a log, or a command that echoes the variable, is a path from the environment to the context, and a value there can be repeated in the next message or page. Research on contextual integrity puts a number on it: GPT-4 and ChatGPT "reveal private information in contexts that humans would not" in 39% and 57% of cases (Mireshghallah et al., 2024).

The scope belongs here, because the answer depends on where the work happens. A governed browser environment covers what an agent reads and does on a rendered page: dashboards, consoles, settings pages and forms. It does not cover the terminal, the IDE, the local filesystem, direct API calls or MCP. The broker below lives in that second list, in the API path between the agent and Vault; a token displayed in a dashboard is a second route to the same value.

Can you scope the token down instead of taking it out of the agent's context?

Scoping is the first thing to do, and it pays. The tutorial's token is read-only, repo-only, limited to one path, and short-lived. A lease bounds a generated credential in time: "All dynamic secrets in Vault are required to have a lease," and "When a lease is revoked, it invalidates that secret immediately and prevents any further renewals" (HashiCorp, Lease, 2026).

The kind of value matters. Vault's own tutorial draws the distinction the design turns on, between a value stored in the engine and a credential generated on request (HashiCorp, Static and dynamic, 2025). A generated credential dies with its lease. A stored password or deploy key works until a person rotates it, so a token that reads it opens a door that stays open.

Scope is also a promise about agent behavior that the agent does not keep. The benchmark that measures policy compliance for web agents reports that "their average CuP [Completion under Policy] is less than two-thirds of their nominal completion rate," so a scope an agent is told to keep is not one it keeps (Levy et al., 2026).

What scoping cannot do is change who holds it. A vault protects the values deposited in it, exactly that set (Can a Credential Vault Protect What an AI Agent Reads?). Scope decides what the token can reach, not whether the process running the model holds it.

What do the vendors themselves say?

HashiCorp's tutorial states the limits on the token it hands an agent: "Token lifetime is reduced from days or weeks to minutes," and the token is "read-only, repo-only, scoped to a single secret, and short-lived" (HashiCorp, Secure agent permissions, 2026).

Response wrapping addresses delivery instead: "Vault includes a feature called response wrapping," which lets a value travel inside a single-use token the recipient unwraps once (HashiCorp, Response Wrapping, 2026). The mechanism is a courier, not a broker: whoever unwraps the token holds the value, and Vault "does not provide signed response-wrapping tokens," so the recipient cannot verify the issuer before spending it.

Dimension HashiCorp Vault, per its documentation What a buyer should verify
Who holds the token A wrapper "exports it as VAULT_TOKEN, and launches the agent" (HashiCorp, Secure agent permissions, 2026) Whether the model's process holds the token
Lifetime "Token lifetime is reduced from days or weeks to minutes" (HashiCorp, Secure agent permissions, 2026) Whether it covers the follow-up work
Revocation A revoked lease "invalidates that secret immediately and prevents any further renewals" (HashiCorp, Lease, 2026) Who can revoke mid-run, and what happens next
Delivery "A new single-use token is generated with the TTL supplied by the client" (HashiCorp, Response Wrapping, 2026) Which component unwraps
Record The request, the token accessor and the lease (HashiCorp, Lease, 2026) Whether it joins the fetch to the action
Screen coverage Not described in the pages reviewed What the agent reads when a token is on a page

How do you put a broker between the agent and Vault?

Four parts make it work, and none is a Vault feature: a read-only policy for the broker on one path with a short lifetime; one broker endpoint per action, so the agent asks to open a pull request, not to read a path; validation of repository, branch and destination before Vault is called; and an approval and a record on the action.

The agent's credential for the broker is a different value: it authenticates a request, is scoped to the run's endpoints, and expires with the task. If it leaks, an attacker gets a surface the broker can log and a person can approve, not a Vault path returning a live credential. That is an improvement, not a guarantee: an agent holding only placeholders can still leak the tokens it has (What Can a Hijacked Agent Leak If It Only Has Placeholders?).

Response wrapping fits inside the broker: it asks Vault for the value, receives it wrapped, unwraps it and makes the call. The tutorial exports the token to the agent; the broker does not.

1Password's write-up describes the shape: "the agent sees placeholders rather than real credentials," and the gateway replaces a placeholder only when the request goes to an approved host (1Password, 2026). What the agent reads is a pull request number or a status, nothing that grants the next action (How Do I Let a Coding Agent Open Pull Requests Without Giving It My Credentials?).

Who approves the broker's call, and what record does it leave?

The approval belongs on the action: a person approves "open this pull request against this repository," and the broker releases what that action needs; nobody approves a token, which is not a decision a person can evaluate. The agent stays tethered to that person for the run, and the tether describes authority rather than capability (What Is a Tethered Agent?).

The research on approval steps is not encouraging. The literature calls the failure mode automation bias and has studied it across fields: "Automation bias (AB), the tendency to over-rely on automation, has been studied in various academic fields" (Goddard et al., 2012). An approval that shows a single yes button and a workflow name trains that over-reliance, and an approver waving through a hundred dialogs a week is not a control.

Vault's side of the record is the fetch. Its pages cover the request, the token and the lease, and stop there: the record shows a credential was issued and revoked, not what the process did with it (HashiCorp, Lease, 2026). The work record joins the agent's request, the broker's action, the approver's name and the value's reference, and it has to leave Vault to serve an incident review (Does HashiCorp Vault Keep Credentials Away From a Coding Agent?).

What does a governed environment change?

The control class that covers the screen works on a different surface from the broker. Values on a rendered page are replaced with consistent tokens before any model reads the screen, so an agent on a settings page sees DEPLOY_TOKEN_01 where the key would be and carries that token through the run. Real values resolve only at an approved destination, at the moment of an approved action, and a named person approves each consequential action first. Every screen the agent read as tokens, and every action and approval, is exported to the organization.

The broker keeps VAULT_TOKEN out of the process that runs the model, so a fetch returns a result, not a credential. The screen control keeps a value out of the context when the agent opens the page that displays it: a token shown once at creation, a key pasted into a form, a deploy key listed on a repository page. Both are needed: a token can travel either route.

Scope returns here: a governed browser environment covers what an agent reads and does on a rendered page, not the terminal, the IDE, the local filesystem, direct API calls or MCP. The broker covers the API path outside that scope, and no browser control substitutes for it. (RedactSure vs HashiCorp Vault: 2026 Comparison & Alternative sets the two approaches side by side.)

What the record shows

The record here is a custody record: what the agent held, what the broker held, and what a person approved. Vault's documentation bounds the life and reach of a credential and offers a delivery token a recipient unwraps once. The tutorial's wrapper exports the delegated token into the environment it launches, and Vault's pages bound what it can reach (HashiCorp, Secure agent permissions, 2026). The broker that holds the token instead is a component an organization writes; the pages reviewed do not describe Vault shipping one. A team can settle it with one test run: give the agent the environment it has today, ask for one read from Vault and one write to GitHub, then compare the token the process held with the token the policy intended and count who could have approved the write. If the same value appears in both, the broker is missing.

Methodology and limitations

This page rests on vendor documentation from HashiCorp and 1Password, two research papers on agent behavior and automation bias, and a RedactSure research page on vaults. Vendor pages were read between October 20, 2026 and October 21, 2026, and each Sources line carries its date. Public documentation read in full gives a sound view of where each product applies its control.

None of the products here was tested for this page, so "not described" means the pages reviewed, and features change, so the page carries its date. The example describes a record type, not an organization. RedactSure is deploying now with enterprise and government customers. Determinations belong to counsel, assessors and the organization's own security and compliance officers, and nothing replaces a pilot of one workflow on its own screens.

Frequently asked questions

Does using Vault with a coding agent expose the token to the model?

Only when the token is placed in the agent's process, which is what HashiCorp's tutorial does: a wrapper script exports the delegated token as VAULT_TOKEN and launches the agent. The exposure is not the fetch, since a fetch is what Vault is for. It is that the process making the fetch runs the model, so a command that prints the environment can carry the value into the context. A broker that fetches on the agent's behalf removes that path.

Can a Vault token scoped to one path be safe inside the agent?

No, though it is far less dangerous than an unscoped one. The tutorial's token is read-only, repo-only, limited to one path and short-lived, and a lease can be revoked when the work ends. Those limits decide what a stolen token can reach. They do not decide who holds it. A value the agent fetched stays in the process after revocation, so scoping limits damage without changing custody.

What does the agent read when the broker returns a result?

Only the result the broker returns: a pull request number, a status, a line in the action record. The credential stays behind the broker's boundary, so the context carries the outcome rather than the value. That holds for the API path. When the agent opens a dashboard or a settings page where a token is displayed, the model reads whatever the page renders, and the broker cannot help.

Who approves the broker's call, and what should the approval show?

A named person, on the action rather than on the credential. The approval is worth exactly what it displays: the repository, the destination, the change and the value about to be released. A screen that offers only a yes button invites the over-reliance the automation-bias literature describes, so the approver should check that the request matches the task before anything is released.

What record does Vault keep, and what does it miss?

Vault records the request: the path read, the token used, the lease issued and any revocation, depending on the audit device configured. That is a record of the fetch. It does not say what the requesting process did next, whether a model read the value, or who approved the action. The missing half is the agent's side, which is why organizations pair the Vault log with a record of screens, actions and approvals.

Does response wrapping keep the token out of the agent?

Only when someone other than the agent unwraps it. Response wrapping puts the value inside a single-use token with a client-supplied lifetime, and the recipient exchanges it for the value once. If that recipient is the agent, the agent holds the value after the exchange. A broker can unwrap on its own side, so the wrapping token and the value both stay outside the process running the model.

About the author

Chris Sowa is a founder of RedactSure and a former CEO of an AI company; he started it years before ChatGPT existed. He previously led AI at Accenture, served as Global VP of Strategy & Innovation at Schneider Electric, was CCO of Sovos, and spent more than a decade at Oracle, with earlier roles at SAP and IBM.

How RedactSure Keeps a Vault Token Out of the Agent's Process

A broker fixes the API path, and a token still reaches a model the first time an agent opens a page that shows it.

The environment that enforces this is built by RedactSure, an AI agent controls, governance and data protection company.

Before, the agent runs with VAULT_TOKEN in its environment and opens the repository settings page to add a deploy key, so the fields it reads and the variable share one context. Inside, it opens the same page, reads DEPLOY_TOKEN_01 in the key field, and the broker releases the real token only after the named person approves, with the approval recorded.

RedactSure is deploying now with enterprise and government customers. GPT-4 and ChatGPT revealed private information where people would not, in 39% and 57% of cases.

Everyone else controls where data can go. RedactSure controls what the AI can see.

See it on your own workflow

The token in the agent's environment is a custody decision, not a setting. Bring a repository task you would give an agent and see, with test values, what it reads on the page, what the approval releases and what the record keeps. Book a demo

Book a demo

Book a demo

Having trouble? Open the booking page or email us.