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:
- Agent can run
cat ~/.openclaw/.env and read plaintext keys
- Agent can run
echo $API_KEY to print environment variables
- Secrets can appear in command outputs and chat history
- 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).
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/.envare fully accessible to agents:cat ~/.openclaw/.envand read plaintext keysecho $API_KEYto print environment variablesProposed Solution
1. Secret Reference Syntax
curl -H "Authorization: Bearer {{secret:MY_API_KEY}}" https://api.example.com2. 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 .env5. Config:
Willingness to Contribute
Happy to implement this if the approach looks good!
This proposal was developed with AI assistance (Claude/OpenClaw).