Credential injection¶
Credential injection keeps API keys out of the tool. The tool gets a random placeholder in the key's env var, new each run, and the egress proxy swaps in the real key on HTTPS requests to the key's hosts. Use it for any static API key you'd otherwise pass with --env or leave in the tool's home.
Usage¶
- Store the key with
agentic secret set, or save it in a one-line file outside your projects, e.g.~/.secrets/anthropic_key. - Add an entry to
.agenticrc.toml, with a preset or your own hosts. See[[run.proxy.credentials]]for the keys and presets.
[[run.proxy.credentials]]
preset = "anthropic"
secret = "~/.secrets/anthropic_key"
[[run.proxy.credentials]]
preset = "github"
secret = "store:github"
# ghe.com tenant
[[run.proxy.credentials]]
preset = "github"
host = "acme.ghe.com"
secret = "~/.secrets/ghe_pat"
[[run.proxy.credentials]]
hosts = ["api.example.com"]
header = "Authorization"
env = ["EXAMPLE_TOKEN"]
secret = "~/.secrets/example_token"
- Run the tool and approve the entry when asked. Each run prints
agentic: injecting credentials for <hosts> (<secret path or store:name>).
With the microsandbox runtime, msb swaps the key in itself, unless agentic-proxy is the backend.
Stored secrets¶
agentic secret keeps named secrets for secret = "store:<name>" and for agentic aqua, which uses the one named aqua:
agentic secret set github --expires 2027-03-01 # asks for the value without echo
agentic secret set aqua < ~/aqua-token # or pipe it in
agentic secret list # or: ls, agentic secrets; names, backends and dates, never values
agentic secret remove github # alias: rm
agentic secret prune # every secret; --yes skips the question
- Where: the OS keychain (macOS Keychain, Windows Credential Manager, Secret Service on Linux). Without one, such as headless Linux or WSL, a private file in the data directory, with a warning.
--fileforces the file. - Keychain refuses: a locked keychain or cancelled prompt fails
set; retry, or use--file. - Replacing:
setasks before replacing a secret;--yesskips that, and is needed when piping the value in. - Expiry: with
--expires, runs andagentic aquawarn from a week before that date. Nothing is blocked. - No re-approval: changing a stored value doesn't change the config entry, so it isn't asked again.
GitHub tokens¶
Use a fine-grained personal access token per use, so the agent can only do what that token allows:
| Use | Repository access | Permissions |
|---|---|---|
Copilot (preset = "github") |
None needed | Account: Copilot Requests |
gh and the GitHub API on your repos |
Only select repositories | Only what the task needs, e.g. Contents and Pull requests read and write |
agentic aqua search/update (aqua) |
Public repositories | None: any token lifts the rate limit |
Set an expiry date on the token and pass the same date to --expires.
gh auth token | agentic secret set github --yes stores the gh CLI's token instead. That token is broad: it reaches every repository you can, never expires and can't be narrowed.
How it works¶
- Proxy on: credentials turn the proxy on in enforce mode, unless monitor mode is set. Their hosts join the allowlist, limited to their paths when
allowed_pathsnames them. - Only credential and path-limited hosts are decrypted, with a per-run CA that can sign nothing else. They use HTTP/2 when the tool offers it, so concurrent requests share one connection, else HTTP/1.1. Other traffic stays an end-to-end encrypted tunnel, and plain HTTP is never touched.
- Only the placeholder is swapped, in the entry's headers (decoding
Basicauth first). A request without it passes unchanged. Look-alike headers such asX_Api_KeyforX-Api-Keyare dropped. - Missing placeholder: if a credential host rejects a request (401 or 403) that never sent the placeholder, the run ends with a warning and the log marks it
no-placeholder, as the tool likely ran unauthenticated. - Secrets stay on the host: read when the run starts and copied into the proxy, which is removed when the run ends. A secret inside the current directory or any mounted path is refused, as is a mount that contains or sits inside the secret store's directory, or running from inside it.
- CA trust: agentic mounts the image's system bundle plus the CA over
/etc/ssl/certs/ca-certificates.crtand pointsSSL_CERT_FILE,CURL_CA_BUNDLE,GIT_SSL_CAINFO,REQUESTS_CA_BUNDLEandNODE_EXTRA_CA_CERTSat it. On thejavabase, the entrypoint adds the CA (and msb's, when msb enforces the allowlist) to a copy of the JDK trust store throughJDK_JAVA_OPTIONS, keeping your options; the JVM printsNOTE: Picked up JDK_JAVA_OPTIONS. These vars and the entries'envnames are reserved.
Limitations¶
- Static keys only: OAuth logins (Claude subscription, Copilot device flow) keep their token in the tool home, where the agent can read it. Setting a key's env var (e.g.
ANTHROPIC_API_KEY) switches the tool to API-key auth. - Headers only: a key sent in the URL or body, or used to sign requests (e.g. AWS SigV4), can't be a placeholder.
- git: git over HTTPS sends no credentials, as no credential helper is set. The
githubpreset covers API calls only. - Copilot: the
githubpreset covers the Copilot API hosts and the remote GitHub MCP server. Withhost, it covers aghe.comtenant's instead, with a PAT-shaped placeholder that secret scanners may flag. - Use, not theft: the agent can't read the key but can still use it on its hosts during the run.
allowed_pathsnarrows that, but a path like GitHub's/graphqlreaches everything, so a token the provider scopes is the stronger limit. - Echoed keys: the proxy swaps the key back in response headers and trailers, not in bodies. A host that echoes the request in its body hands the key to the tool.
- CA trust gaps: containers started through
--dinddon't trust the CA, nor does Java underrun -- <cmd>, so TLS to credential and path-limited hosts fails there.