Skip to content

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

@jmkritt

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

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions