-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
Bug: /token/i regex in redaction mechanism falsely matches maxTokens, causing config corruption on update #13236
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
The sensitive field redaction mechanism uses overly broad regex patterns to identify fields that should be masked:
const SENSITIVE_KEY_PATTERNS = [
/token/i,
/password/i,
/secret/i,
/api.?key/i
];The /token/i pattern matches maxTokens (a numeric config field for max token count), which is not a sensitive credential.
Impact
When certain code paths (e.g., extension API /config set) write config back to disk without calling restoreRedactedValues(), the redacted placeholder __OPENCLAW_REDACTED__ overwrites the original numeric value of maxTokens.
This also affects actual sensitive fields (channels.discord.token, channels.telegram.botToken, channels.feishu.appSecret) — their values get permanently replaced with the placeholder string if the round-trip write happens.
This issue consistently reproduces after version updates.
Steps to Reproduce
- Have a working
openclaw.jsonwithmaxTokens: 16384and valid channel tokens - Update OpenClaw to a new version
- Observe that
maxTokensis now"__OPENCLAW_REDACTED__"instead of16384 - Channel tokens may also be corrupted
Expected Behavior
maxTokensshould NOT be redacted (it is not a sensitive credential)- Config write-back should always restore redacted values before persisting
Suggested Fix
- Narrow the regex: Use
/^(?:bot)?token$/ior match full field names instead of substrings - Whitelist non-sensitive fields: Explicitly exclude
maxTokens,maxOutputTokens, etc. - Guard all write paths: Ensure
restoreRedactedValues()is called before any config persistence - Add a round-trip test: Read config → redact → restore → compare with original
Environment
- OpenClaw: 2026.2.9
- OS: macOS (arm64)
- Node: v25.6.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.