openclaw - 💡(How to fix) Fix Feature Request: Protect secret tokens in config from model context leakage (headers, URLs) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58915Fetched 2026-04-08 02:31:13
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
closed ×1locked ×1
RAW_BUFFERClick to expand / collapse

Feature Request

Problem

openclaw.json contains sensitive credentials that get injected into the system prompt and agent context via workspace files (e.g., TOOLS.md, AGENTS.md, project context blocks). This means LLM models can potentially read:

  1. Bearer tokens in MCP server URLs — e.g., MCP server configs with ?key=<SECRET_KEY> embedded in plain text
  2. API keys in channel config — Telegram botToken, Matrix accessToken appear in full in the config
  3. Gateway auth tokensgateway.auth.token visible in system context
  4. Any token in URL query parameters?key=xxx, ?token=xxx patterns
  5. Any token in custom headersAuthorization: Bearer xxx, X-API-Key: xxx

The real danger: When agents are given full config access, the model receives all secrets in context. A compromised or malicious model (or one that is jailbroken) can exfiltrate these credentials through its responses.

Current situation

  • openclaw.json secrets appear in agent session context
  • Auth profiles (auth.profiles) are visible to agents
  • Channel credentials (botToken, accessToken) are loaded into context
  • MCP server URLs with embedded keys (?key=xxx) are loaded into context
  • No redaction of these values before they reach the model

Proposed solutions

  1. Auto-redact secrets in agent context

    • Replace token values with [REDACTED] markers in the prompt/context sent to models
    • Support patterns: ?key=..., ?token=..., Authorization: Bearer ..., botToken, accessToken, gateway.auth.token
  2. Secret scope isolation

    • Introduce a scope: "secret" or scope: "system" annotation for config keys
    • Values with this scope are available to the gateway runtime but NOT injected into model context
    • Similar to how redactSensitive: "tools" currently works for tool outputs
  3. URL-level key extraction

    • Parse MCP/tool URLs and extract ?key=, ?token= parameters into separate secret references
    • Store them as secret refs instead of plaintext URLs
  4. Header-level token protection

    • Allow headers in tool/MCP config to use secret ref syntax
    • Gateway resolves at runtime, model only sees the ref metadata, not the actual token value
  5. Extend secret ref support for URL tokens

    • Extend the 2026.3.28 env secret ref feature to also support URL query parameters

Priority

High — This is a security concern. Any agent with config-reading capability (which is the default) exposes all embedded credentials to third-party LLM providers.

Suggested labels

security, enhancement, auth, secret-management, context-isolation

extent analysis

TL;DR

Implement auto-redaction of secrets in agent context to prevent exposure of sensitive credentials to LLM models.

Guidance

  • Identify and prioritize sensitive credentials in openclaw.json that are currently exposed to LLM models, such as bearer tokens, API keys, and gateway auth tokens.
  • Consider implementing one of the proposed solutions, such as auto-redacting secrets in agent context or introducing scope isolation for config keys.
  • Evaluate the feasibility of extending secret ref support for URL tokens to further enhance security.
  • Assess the potential impact of these changes on existing workflows and tool configurations.

Example

No specific code example is provided due to the lack of technical implementation details in the issue.

Notes

The proposed solutions aim to address the security concern of exposing sensitive credentials to LLM models. However, the implementation details and potential trade-offs need to be carefully evaluated to ensure the chosen solution effectively mitigates the risk without introducing unintended consequences.

Recommendation

Apply workaround by implementing auto-redaction of secrets in agent context, as it appears to be a straightforward and effective solution to address the immediate security concern.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING