Log date · Sun
How should LLM agents handle API secrets?
Keep secrets out of agent context and attach them at a trusted, authorized request boundary. We compare two local handoffs.
Keep the key outside the agent context
Keep API keys out of an agent’s prompts, tool descriptions and model-readable configuration. Let the model name a connector; a trusted execution boundary checks the destination and action before attaching credentials. In our toy sample, a placeholder key appeared in the direct context but not in the connector-only context. Of three simulated requests, the allowed read succeeded; a different origin and a write were denied.
| Question | Result |
|---|---|
| Was the placeholder in context? | Direct: yes; connector only: no. |
| What happened at the request boundary? | The allowed read succeeded; another origin and a write were denied. |
| What did the paper establish? | All 16 probes met expected outcomes in a small functional evaluation, not a certification. |
This design reduces opportunities for a credential to enter conversations, logs and tool results, but it does not by itself decide whether an agent may perform an action. At 08:55 UTC on 2026-09-27, Patrick Kenney and co-authors submitted v1 of arXiv 2609.33371, primarily classified cs.CR; the paper examines this execution boundary. [1]
A local comparison of two handoffs
We used Node.js 20.19.5 to write a parent and a child process standing in for an agent. In the first case the context contains a fake key; in the second it contains only catalog. The child checks its serialized input for the placeholder prefix. The parent then simulates an execution boundary that permits only a specified origin and read action. There is no model, network, real vault or external service here: this is an illustration with another tool, not a replication of the paper or a test of its product.
The child starts with an explicitly empty environment. Node documents the env option for supplying a child process environment. [2] This makes the comparison clearer, but an empty environment is not a security sandbox: real isolation also depends on files, process permissions, network and other communication channels.
Node: v20.19.5
direct: {"contextHasSecret":true,"connector":"catalog"}
mediated: {"contextHasSecret":false,"connector":"catalog"}
allowed: accepted fake authentication
other origin: denied
write action: deniedThe sample’s “accepted” result is just the parent comparing a placeholder string; it is not an HTTP request. The detector looks for one prefix and cannot prove a real system contains no other secrets. The useful distinction is what data is handed to the agent and which component may attach authentication.
What the paper measured
The paper proposes that the model select a connector identifier while a trusted request boundary supplies authentication for its configured origin. The authors ran two controlled black-box experiments on a production implementation: all 16 probes across seven control domains met their expected outcomes. They also reported a negative result: a connector’s stored header mapping did not meet its provider’s authentication contract. [1] Even with centralized custody, verify that each connector actually authenticates as its provider requires.
This was a small, purposively sampled functional evaluation, not a certification. Even without seeing a credential, a model can be influenced by untrusted content to call a tool it is allowed to use. Enforce deterministic checks outside the model on user identity, connector, destination, operation and parameters; require independent approval for high-impact actions. Test credential custody and action authorization separately.
Recommendations for common cases
These are design recommendations, not security gains measured by our sample. Map data flow between the client, agent, execution boundary and provider first. Then establish what each component can read and what it may do.
| Case | Recommendation |
|---|---|
| A client calls a model API | Keep the provider key server-side; authenticate users and apply quotas. |
| An agent calls an external service | Expose a connector ID; enforce allowed destinations, actions and parameters at the boundary. |
| Users supply their own keys | Isolate them per user in controlled storage; keep them out of model context and logs. |
| A credential is exposed | Revoke or rotate it, inspect usage and verify the old credential no longer works. |
Give each connection only the privileges it needs and restrict which components can read secrets. OWASP’s secrets guidance also recommends rotation, revocation and avoiding plaintext secret logging. [3] Logs can record a connector ID, action, result and correlation identifier; check headers, bodies and error messages for sensitive values before recording them.
Short-lived tokens also need refresh and failure handling. For a user-supplied key, revoking provider access and deleting your stored copy are separate operations. Decide who can rotate it, who informs the user after exposure and how to verify the old value is invalid at the provider.
Check your own application
Trace a unique fake placeholder through your own test environment. The command below checks a test capture for that placeholder; replace the path with your own test output. Use fake values in a controlled environment and keep real keys out of command lines and shared reports.
# In your project, replace the path with a controlled test capture.
grep -F -l -- "DEMO-KEY-not-a-real-credential-0000" path/to/test-capture.txtCapture model inputs, tool arguments, tool results, errors and redacted logs separately, then check whether the placeholder reaches any place it should not. No match means only that this capture lacked the complete literal: encoding, truncation, uncovered paths or collection gaps can miss it. Also test a successful call to the intended destination, rejection of another destination, rejection of an unauthorized action, and a real call after credential rotation.
Finally inspect client release artifacts and historical logs. Removing a key from code does not invalidate a credential already exposed. Record the location and scope of a finding without copying the key into a ticket.
Your checklist
- Check prompts, tool inputs and outputs, and logs for a test placeholder.
- Enforce connector destinations, actions and parameters at a trusted boundary.
- Give each connection least privilege and test provider authentication.
- Establish rotation, revocation and verification of old credential invalidation.
- Inspect client release artifacts and historical logs for exposure.
Primary sources
- arXiv: API Secrets Should Never Become Tokens in the LLM's Vocabulary (2609.33371) · Source date 2026-09-27 · Checked 2026-10-12
- Node.js: Child process · Checked 2026-11-11
- OWASP: Secrets Management Cheat Sheet · Checked 2026-11-11