Scoping a coding agent to one secret, tool by toolThe smallest grant each manager allows
The 1Password CLI authorizes a whole account for a terminal session, so an agent started in that terminal can read every vault you can. Every major manager has a smaller unit, usually a token bound to one vault, project, config or path, and none of them stop the agent from sending the value it was given somewhere else. Pick the smallest unit your tool offers, give the token an expiry, and keep it out of your interactive shell.
-
01
Login
Whole account
Biometric unlock covers every vault
10 min idle, 12 h max -
02
Token
One scope
Vault, project, config or ARN
Expiry is optional -
03
Process
Value in env
Agent can still send it anywhere
Scope limits reads only
TL;DR· the answer, in twenty seconds
What happened: On November 15 Marc Köhlbrugge asked on X how to give coding agents credentials safely, because 1Password "gives an agent access to the full vault every time." The post drew 295 replies. 1Password documents the cause: its CLI app integration authorizes a whole account for a terminal session and its sub-shells.
The minimum fix: Stop running agents inside a terminal where you have unlocked your personal manager. Create a non-human identity scoped to the smallest unit your tool supports, give it an expiry, and hand only that token to the agent's commands.
The lesson: Scope decides what an agent can read. It does nothing about what the agent does with a value once it holds it, so short lifetimes and per-command delivery matter as much as the scope.
On November 15, Marc Köhlbrugge asked on X whether anyone had "found a secure and usable way to provide their coding agents with credentials," adding that 1Password "gives an agent access to the full vault every time." By November 18 the post showed 125.9K views and 295 replies.
The replies split into camps. Prasenjit Sarkar answered that the agent "needs exactly one credential, for exactly one call, and it should never actually see it," and argued for a proxy. Another reply from @256BitChris listed AWS Secrets Manager, dotenvx, OIDC keyless workflows and fine-grained Bitwarden credentials, and said the agent should trigger a workflow instead of holding a secret. Tapio Vepsäläinen's post on sharing secrets with LLM agents reached Hacker News the same week with a third answer: hand the agent expendable tokens and keep the real ones behind a local proxy in a sandbox.
Before you pick a camp, answer a narrower question. What is the smallest grant each tool you already pay for can issue to a non-human caller? This guide answers that for 1Password, Bitwarden, Doppler, Infisical, AWS Secrets Manager and HashiCorp Vault, from each vendor's documentation as we read it on November 18. We did not create accounts or run these products for this piece, so every scope below is the vendor's claim. Each command below names the vendor doc it came from.
Why 1Password hands over the account
Köhlbrugge's complaint is a documented property of how op signs in on a developer machine. When you turn on the desktop app integration, the CLI asks for Touch ID or your system password and then holds a session. 1Password's app integration security page gives the terms:
- Authorization is per account. Approving one
opcall authorizes that account, every vault you can see included. - The session lasts 10 minutes and refreshes each time you use it, with a hard limit of 12 hours.
- On macOS and Linux the session is confined to the terminal window where you approved it, and it extends to sub-shell processes in that window.
The last point decides the outcome. You open a terminal, run op read once to fetch a key, then start Claude Code in the same window. The agent is a child of that shell. For the next 10 minutes, and as long as something keeps using the session, any op command the agent runs inherits your authorization across the account. A prompt-injected agent can run op item list and walk your personal vault without another prompt.
1Password lists a few accepted risks on the same page, including processes running as root and apps holding macOS accessibility permissions, which may get past the prompt. Those matter less here. The agent doesn't need to bypass anything, because you approved the session it inherits.
Nothing about this is a bug. 1Password built the app integration for a human at a keyboard, and a human at a keyboard wants the whole account. The fix is to give the agent a different identity.
The smallest grant in each tool
Every manager on this list has a non-human identity with a narrower scope than a person's login. They differ on how narrow that scope can get, whether it can expire, and what a leaked token lets an attacker do.
| Tool | Non-human identity | Smallest scope | Expiry | Notes from the docs |
|---|---|---|---|---|
| 1Password | Service account | Chosen vaults, with read_items, write_items or share_items per vault |
--expires-in at creation |
Can't be granted Personal, Private, Employee or the default Shared vault. Permissions can't change after creation |
| Bitwarden Secrets Manager | Machine account and access token | A project, with "Can read" or "Can read, write" | Set per access token. Default is never | Event logs record each "Accessed secret". Anyone added to the machine account can mint tokens for it |
| Doppler | Service token | One config in one project, read-only by default | Optional, down to minutes for ephemeral tokens | Revoking a token leaves the last fetched secrets in the CLI's encrypted fallback file |
| Infisical | Identity with a project role | Built-in roles cover all environments in a project | Not covered on the page we read | Roles limited to specific secrets, folders or environments need the Enterprise plan |
| AWS Secrets Manager | IAM role or user | One secret ARN | Through the role's session credentials | A secret under a customer-managed key also needs kms:Decrypt |
| HashiCorp Vault | Token with attached policies | One path | Token TTL | Deny by default. An empty policy grants nothing |
| hasp 1.0.48 | Per-command grant from a local broker | One named secret for one command | once, session or a set window |
Local only. The child process receives the value |
Three rows can scope to a single secret: AWS, Vault and the local broker. The rest stop at a container that holds secrets, which means you shape the container to fit the agent.
1Password service accounts
A service account is the answer to Köhlbrugge's question inside 1Password. You pick the vaults it can reach and the permission on each, and the CLI uses it when OP_SERVICE_ACCOUNT_TOKEN is set instead of the desktop session. 1Password blocks service accounts from the built-in Personal, Private and Employee vaults and from the default Shared vault, so the agent can't be pointed at your personal items by mistake.
The smallest unit is a vault. If you want the agent to read one key, create a vault that holds one key. You can't change permissions after creation, so a wrong scope means deleting the account and making a new one. An account can hold up to 100 service accounts, and service accounts get read-only access to 1Password Environments.
Pair the service account with op run, which resolves secret references into a child process's environment and masks the values in its output by default. That keeps the token's reach to one vault and the values to one process.
Bitwarden machine accounts
Bitwarden's machine accounts attach to projects, and each project grant is either "Can read" or "Can read, write." The smallest useful scope is a project, so the advice matches 1Password's: build a project for the agent's task.
Bitwarden is the strongest of the group on after-the-fact audit. Each read appears in the event log as "Accessed secret" (event type 2100), logs are kept indefinitely, and you can export up to 367 days at a time. When an agent misbehaves, you can see which secrets it touched.
Two rules deserve a look before you rely on it. Access tokens default to an expiry of never, so set one when you create the token. Revoking a token stops new logins, but Bitwarden says a machine that already authenticated may keep retrieving and decrypting secrets for up to an hour. And anyone added to a machine account can generate access tokens for it, so every member can mint a new credential with the same reach.
Doppler service tokens
A Doppler service token reads one config in one project, which is the narrowest container-level scope on this list. Write access is opt-in, and expiry is optional.
Doppler also supports ephemeral tokens with a maximum age. The docs show a one-minute token:
# From Doppler's service token docs. Run as a human, outside the agent's shell.
doppler configs tokens create ephemeral-token --max-age 1m --plain
Two details from the same page change how you use it. Doppler tells you not to use CLI or personal tokens in live environments, which describes exactly the setup most developers have when they start an agent. And revoking a service token does not clear secrets the CLI already fetched. Those stay in its encrypted fallback file on disk, so after a suspected leak, rotate the secret as well as the token.
Infisical roles
Infisical's role-based access controls give every plan, including free self-hosting, four built-in project roles: Admin, Member, Viewer and No Access. Member reads and writes across every environment in the project, and Viewer reads across every environment. Neither fits "one secret."
Custom roles that limit access to particular secrets, folders or environments require the Enterprise plan. The docs also describe pairing No Access with additional privileges to open a single environment or secret path. We could not load that page, so we have not confirmed which plans include it. Permissions from multiple roles add up, so a second role can widen access you narrowed with the first.
Infisical's other answer is Agent Vault, a proxy that attaches credentials on the agent's behalf. We covered where it stands in the October launch comparison.
AWS Secrets Manager and Vault
Both reach a single secret, and both put the effort on you to write the policy. AWS identity policies can name one secret ARN:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret"],
"Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:secretName-AbCdEf"
}
]
}
That is the shape AWS documents. If a customer-managed KMS key encrypts the secret, the role also needs kms:Decrypt on that key.
Vault's policy docs state that "everything in Vault is path-based" and that policies "are deny by default." A policy granting read on one KV path gives a token that one path.
The catch with both is the credential that unlocks the policy. An agent on a laptop needs AWS keys or a Vault token to fetch the secret, and that bootstrap credential sits somewhere the agent can read. In CI, OIDC removes it, which is why @256BitChris's reply leaned on keyless workflows. On a laptop it is one more token to scope and expire.
What a scoped token leaves open
Scope limits what an agent can fetch. It does not change what happens after the fetch. Every row in the table, ours included, ends with the value in a process the agent controls or launched. Sarkar made this point about Vault and AWS: they still hand the workload the secret. The same holds for every container-scoped token above.
So a tight scope buys you three things and no more:
- A hijacked agent can't wander from the key it needs into your bank login, your SSH keys or another client's production database.
- A leaked token exposes one vault, project, config or path, and the blast radius is something you can list from memory.
- Rotation after an incident covers a known, short set of secrets.
It does not stop an injected instruction from sending the one key the agent holds to an attacker's host. For that you need either a proxy that keeps the value out of the agent's process, as Sarkar and Vepsäläinen argue, or egress control on the machine. Both work best in a sandbox. Our earlier guide on least-privilege scopes covers the other half: limit what the key itself can do at the provider, so a stolen test key can't touch production.
The scoped token also becomes a secret of its own. 1Password's post on reducing credential exposure says the "bootstrap credential still needs to be protected and carefully scoped." If you export OP_SERVICE_ACCOUNT_TOKEN in your shell profile, every process you start, the agent included, holds it for as long as the token lives. Put a short expiry on it and set it only for the commands that need it.
A setup that holds up today
For a coding agent on your own machine, this is the order we would work in.
First, separate the agent from your login. Don't start an agent in a terminal where you approved op, bw or doppler login for yourself. Open a fresh terminal, or run the agent under a different user. This step alone closes the inherited-session hole Köhlbrugge hit.
Second, create a container for the agent's task and nothing else. In 1Password that is a vault, in Bitwarden a project, in Doppler a config. Put the test-mode keys the agent needs in it. If you find yourself copying production keys in, stop and ask whether the task needs production.
Third, issue a non-human token for that container with an expiry. From 1Password's docs, adapted to a read-only grant on one vault:
# Run as a human, outside the agent's shell.
op service-account create "claude-code-test-keys" \
--expires-in 24h \
--vault agent-test-keys:read_items
1Password's own example also passes --can-create-vaults and grants write_items. An agent that only reads keys needs neither.
Fourth, deliver the value per command. Wrap the commands that need secrets with op run, doppler run or your tool's equivalent, with the token set in that command's environment and nowhere else. An agent that runs npm test through a wrapper gets the key for that test run. An agent with the token exported in its shell gets it for the token's lifetime.
Fifth, read the logs. Bitwarden's event log, Vault's audit device and CloudTrail all record secret reads. Look at them after the first week and see whether the agent fetched what you expected.
What this means for your stack
Open a terminal you use for agents and run env | grep -Ei 'token|op_|doppler|bws|vault|aws' | cut -d= -f1 from inside the agent's shell tool. Any name that comes back is something the agent already holds. Check whether that terminal has an unlocked password manager session, and if it does, move the agent out of it today.
The pattern that fixes this category has two parts. A non-human identity with the narrowest scope the tool supports decides what the agent can read. Delivery to one command at a time decides how long it holds what it read. Most teams have the first part available and skip it, and almost nobody does the second.
hasp is one working implementation of per-command delivery, with grants on a single named secret instead of a vault or project. After hasp setup, hasp run --project-root . --grant-secret once --env OPENAI_API_KEY=@OPENAI_API_KEY -- npm test gives that key to one test run and leaves the agent's shell without it. Source-available (FCL-1.0), local-first, macOS and Linux, no account.
Whatever tool you use, keep the agent's identity separate from yours. An agent that runs as you can read what you can read, and no vault layout fixes that until the agent has a login of its own.
Sources· cited above, in one place
- Marc Köhlbrugge on X 1Password gives an agent access to the full vault every time
- 1Password 1Password app integration security
- 1Password Get started with 1Password Service Accounts
- 1Password op run command reference
- Bitwarden Machine accounts
- Doppler Service tokens
- Infisical Role-based access controls
- AWS Secrets Manager identity-based policies
- HashiCorp Vault policies
Stop handing the agent your real keys.
hasp keeps secrets in one local encrypted vault, brokers them into the child process at exec, and never lets the agent read the value.
- Local, encrypted vault — no account, no cloud, no telemetry by default.
- Brokered run — agent gets a reference, the child process gets the value.
- Pre-commit + pre-push hooks catch managed values before they ship.
- Append-only HMAC audit log answers "did the agent touch the prod token?" in seconds.
macOS & Linux. Source-available (FCL-1.0, converts to Apache 2.0). No account.