Skip to content

Feature Request: Masked Secrets - Prevent Agent from Accessing Raw API Keys #10659

Description

@jmkritt

Summary

Add a "masked secrets" system that allows agents to use API keys without being able to see them. This prevents accidental leaks and protects against prompt injection attacks designed to extract credentials.

Problem

Currently, secrets stored in ~/.openclaw/.env are fully accessible to agents:

  1. Agent can run cat ~/.openclaw/.env and read plaintext keys
  2. Agent can run echo $API_KEY to print environment variables
  3. Secrets can appear in command outputs and chat history
  4. Prompt injection attacks could trick an agent into revealing secrets

Proposed Solution

1. Secret Reference Syntax

curl -H "Authorization: Bearer {{secret:MY_API_KEY}}" https://api.example.com

2. Runtime Substitution — Gateway substitutes the real value before execution

3. Output Redaction — Any leaked secret replaced with [REDACTED]

4. Blocked Commands — Prevent echo $VAR, env, cat .env

5. Config:

secrets:
  mask:
    - MY_API_KEY
    - ANOTHER_SECRET

Willingness to Contribute

Happy to implement this if the approach looks good!

This proposal was developed with AI assistance (Claude/OpenClaw).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestimpact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions