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
Credential Proxy Overview
Secrets Management
Environments
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
account (init / login / logout)
server (get / set / status / reset)
secrets (set / list / delete / push / pull)
proxy (start / stop / status / logs)
call (inject requests via proxy)
env (execute commands with secrets)
workspace (list / create / switch / roles)
project (list / create / use / update)
environment (list / switch / copy / merge)
agent (register / list / tokens)
agent policy (set / get / delete)
logs (list / watch / export / verify)
mcp (serve / install / config)
status (system & session diagnostics)
Aliases & Shortcuts
docs (interactive terminal viewer)
Shell Autocompletion
keychain-auth (daemon & security)
Ecosystem Overview
Zero-Knowledge MCP Server
Integrations Overview
Claude Desktop
Cursor IDE
OpenClaw
HTTP Proxy (Any Client)
LangChain (Native)
CrewAI (Native)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
ZK-MCP Integration Guide
Server Overview
5-Layer Architecture
Self-Hosting Guide
Self-Hosting Operations Manual
Server Data Migration
Authentication & Keys
Workspaces & Teams Backend
Projects & Scope Backend
Environments Backend
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint Reference
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API 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.x
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
The Credential ProxyResponse Body Redaction

Response Body Redaction & Echo Defense

When an AI agent makes an API call through the Credential Proxy, the agent only specifies a key name reference (e.g. STRIPE_KEY). The proxy injects the real cryptographic value at the network transport layer, ensuring the agent never has the secret in memory.

However, an insidious vulnerability exists at the HTTP layer: Credential Echo Exfiltration.

Many third-party APIs inadvertently echo authorization credentials back in HTTP response bodies or error payloads:

  • Stripe Error Payloads: If a request fails with an invalid key, Stripe may echo the key back in the error message: "Invalid API Key provided: sk_live_51..." or partially masked: "RESTRICT*DDUH".
  • OAuth & Redirect Handlers: Identity providers often echo the Bearer token or authorization code in redirect parameters or URL-encoded response fields.
  • OpenAI & Anthropic SDKs: Verbose error messages often include debugging fragments containing client-side credentials.

If this response reaches the AI agent, the secret is immediately placed into the LLM's context window, completely bypassing your zero-exposure architecture.

To defeat this attack vector, the AgentSecrets Credential Proxy executes an inline Real-Time Response Body Scanner & Redaction Engine.


How Response Redaction Works

Every HTTP response received from an upstream service passes through redactSecretFromResponse in the proxy engine before being delivered to the calling client:

Loading diagram...

Under the Hood: The 4-Stage Candidate Pattern Matcher

A naive exact-string match (bytes.ReplaceAll) fails in production because APIs frequently alter, escape, or mask credentials before echoing them.

The Go proxy engine (pkg/proxy/engine.go) executes a 4-stage replacement pipeline:

1Exact Plaintext Substitution

The engine first replaces verbatim occurrences of the injected secret:

body = bytes.ReplaceAll(body, []byte(secretValue), []byte(redactionPlaceholder))
  • Placeholder: [REDACTED_BY_AGENTSECRETS]

2URL-Percent Escaped Matching

If the credential was echoed in an OAuth redirect parameter, URL query string, or form-urlencoded body:

urlEncoded := url.QueryEscape(secretValue) if urlEncoded != secretValue { body = bytes.ReplaceAll(body, []byte(urlEncoded), []byte(redactionPlaceholder)) }

3JSON String Escaping

If the API returns a JSON response where special characters (such as double quotes or backslashes) are escaped (e.g. \" inside nested JSON string attributes):

jsonEscaped := strings.ReplaceAll(secretValue, `"`, `"`) if jsonEscaped != secretValue { body = bytes.ReplaceAll(body, []byte(jsonEscaped), []byte(redactionPlaceholder)) }

4Masked Prefix Regex Matching (Echo Obfuscation)

APIs like Stripe and OpenAI often truncate or mask echoed keys (e.g. sk-proj-****xxxx or sk_live_51A****).

The proxy engine pre-compiles and memoizes dynamic prefix regexes in redactionRegexCache (bounded to 256 compiled expressions):

escapedPrefix := regexp.QuoteMeta(secretValue[:prefixLen]) pattern := escapedPrefix + `[\*\.\-_#]{1,4}[^\s"'\,}\]]{0,30}`

If an API echoes a partially masked key that leaks the beginning and ending fragments, the scanner detects the prefix pattern and redacts the entire masked cluster.


Wire-Level HTTP Transformations

When response redaction alters the payload, the proxy automatically updates the HTTP transport framing:

  1. Content-Length Recalculation: Because [REDACTED_BY_AGENTSECRETS] may have a different byte length than the original secret, the proxy recalculates and updates the Content-Length header to prevent connection stalls or truncated payloads.
  2. Chunked Transfer Encoding: If the upstream response uses chunked transfer encoding (Transfer-Encoding: chunked), the proxy buffers the chunks, executes the redaction pass, and re-encodes the chunks cleanly for the client.
  3. Audit Notification Header: The proxy injects an audit header into the HTTP response delivered to the client:
    X-AS-Redacted: true
    This allows client libraries, SDKs, and observability middleware to detect that an echo occurred without reading the body.

Audit Trail & Event Telemetry

Every redaction event is recorded as a high-severity security alert in the AgentSecrets local audit trail:

  • Event Type: credential_echo
  • Logged Fields: Timestamp, target domain (api.stripe.com), HTTP method (GET/POST), response status code (400), and the secret key name (STRIPE_KEY).
  • Zero Plaintext Principle: The echoed value itself is never written to the audit log. Only the fact that an echo occurred and the target endpoint are recorded.

Viewing Echo Events in the CLI

agentsecrets proxy logs --last 10

Output:

14:23:01 POST api.stripe.com/v1/charges STRIPE_KEY 400 credential_echo 184ms
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.