What is AgentSecrets?
The Zero-Knowledge Difference
How AgentSecrets Works
Installation
Quick Start
Migrating from .env Files
Migrating from Vault / AWS
Migrating from dotenv-vault
Production Checklist
Credential Exposure
What Zero-Knowledge Means
The Proxy Model
The Three-Layer Model
Environments
Agent Identity
Storage Modes
The No get() Principle
Secret-Level Policies
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API Reference
Account (init / login)
Server & Self-Hosting (server)
Docs
Shell Autocompletion
Keychain Auth
Secrets
Environments
Credential Proxy
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
Integrations Overview
Claude Desktop
Cursor
OpenClaw
HTTP Proxy (Any)
LangChain (Soon)
CrewAI (Soon)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
Ecosystem Overview
Zero-Knowledge MCP Server
Server Overview
5-Layer Architecture
Self-Hosting Guide
Authentication & Keys
Workspaces & Teams
Projects & Scope
Environments
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint Reference
Security Overview
Anti-Impersonation & Process Verification
Encryption Model
Zero-Knowledge Sync
Proxy Security Layers
Threat Model
OWASP Top 10 Mitigation
Security FAQ
Third-Party Audit
Reporting Vulnerabilities
Guides Overview
Building on the SDK
Stripe Integration
OpenAI Integration
Multi-Agent Setup
Onboarding Team
CI/CD Pipeline
Publishing ZK MCP
Rotating Credentials
Auditing Team Activity
Dev to Production
Kubernetes Deployment
Monorepo Setup
Production Proxy Hardening
vs .env Files
vs HashiCorp Vault
vs AWS Secrets Manager
vs dotenv-vault
vs Infisical
When Not to Use
Proxy Not Starting
Proxy Not Resolving
Domain Blocked
Sync Conflicts
MCP Not Connecting
Session Token Errors
Proxy Session Authorization
Keychain Storage & Backends
SSRF & Destination Rules
Installation Issues
Error Codes Reference
Frequently Asked Questions
v3.1.x
v3.0.0
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
CLI ReferenceHow Injection Works

How Credential Injection Works

AgentSecrets intercepts outbound requests at the transport layer on your local machine, keeping credentials entirely out of your application process space. This document details the step-by-step lifecycle of how a secret is resolved, injected, and audited.


The per-request lifecycle

When your code or SDK makes an API call through AgentSecrets, it goes through a highly secure, multi-stage processing pipeline before the request ever hits the network.

Loading diagram...

How the proxy resolves the key name

The local proxy daemon acts as a secure container. It does not load all secrets into memory at boot time. Instead, it resolves them on-demand:

  1. Header Parsing: The proxy reads the incoming headers to extract the target key name (e.g., STRIPE_KEY) and the requested injection style.
  2. Context Resolution: The proxy determines the active workspace, project, and environment by reading the .agentsecrets/project.json file in the directory where the calling client is running, or from the active session config.
  3. Keychain Query: It queries the OS Keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service) for the active project-environment namespace.
  4. Hardware Decryption: If the keychain is protected by a hardware Secure Enclave or TPM, the proxy negotiates access using the local user's cryptographic identity generated during agentsecrets init. The plaintext credential is materialised in memory only for the duration of the HTTP request lifecycle.

Injection at the transport layer

Once the plaintext secret is resolved, the proxy performs transport-layer rewriting.

  • SSL/TLS Termination: The local application talks to the proxy over a local HTTP connection (or a locally trust-signed HTTPS connection). The proxy terminates this connection, rewrites the request headers, and initiates a brand new, secure outbound HTTPS connection (TLS v1.3) to the target API endpoint.
  • Header Rewriting: The proxy removes all X-AS-* control headers. It then dynamically populates the appropriate standard authentication headers (such as Authorization) or query parameters before transmitting the payload.
  • Volatile Memory: Plaintext secret values are held in memory as transient byte arrays. They are immediately overwritten or garbage-collected once the outbound request socket is opened.

What leaves the proxy and what does not

Understanding the security boundary is critical. Plaintext credentials never leave the boundary of your local machine.

Data ElementIn local application processSent to Local ProxySent over Internet to Target API
Plaintext CredentialsNoNoYes (via HTTPS)
Secret Reference NamesYesYesNo
X-AS-* Control HeadersYesYesNo
Target API EndpointsYesYesYes
Audit LogsNoYesYes (Metadata only, no values)

Annotated example request

To see exactly how this transformation looks in practice, compare the HTTP payload sent by your application to the proxy with the actual payload transmitted by the proxy to the target API.

1Request from application to local proxy

Your application sends the key reference name STRIPE_KEY and target information:

POST /proxy HTTP/1.1 Host: localhost:8765 X-AS-Target-URL: https://api.stripe.com/v1/charges X-AS-Inject-Bearer: STRIPE_KEY Content-Type: application/json Content-Length: 43 {"amount": 2000, "currency": "usd"}

2Rewritten request sent to Stripe

The proxy validates that api.stripe.com is on the workspace allowlist, retrieves the value for STRIPE_KEY (sk_live_abc123) from the keychain, and rewrites the request:

POST /v1/charges HTTP/1.1 Host: api.stripe.com Authorization: Bearer sk_live_abc123 Content-Type: application/json Content-Length: 43 User-Agent: AgentSecretsProxy/1.4.0 {"amount": 2000, "currency": "usd"}

Notice that the X-AS-* headers are completely stripped, and the target server only receives a standard, authenticated API request.

Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.