#23654: security(cli): redact sensitive values in config get output
cli
size: XS
Cluster:
Config Redaction Improvements
## Summary
`runConfigGet()` reads raw config values but never applies redaction before printing. Running `openclaw config get gateway.token` leaks the real credential to the terminal — visible in shell history, scrollback, and screenshots.
This is a 1-line fix using the existing `redactConfigObject()` from `redact-snapshot.ts` (already used by the Web UI path) to scrub sensitive fields before output.
Supersedes #13777 (rebased against current HEAD after upstream refactored `config get` into `runConfigGet()`).
Fixes #13683
## Changes
- Import `redactConfigObject` from `../config/redact-snapshot.js`
- Apply `redactConfigObject(snapshot.config)` before `getAtPath()` in `runConfigGet()`
## Test plan
- [ ] `openclaw config get gateway.token` → prints `__OPENCLAW_REDACTED__` instead of real token
- [ ] `openclaw config get gateway.token --json` → prints `"__OPENCLAW_REDACTED__"`
- [ ] `openclaw config get agents` → non-sensitive paths return real values unchanged
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes a security vulnerability where `openclaw config get` commands leaked sensitive credentials (tokens, passwords, API keys) to terminal output, shell history, and screenshots. The fix applies the existing `redactConfigObject()` function from `src/config/redact-snapshot.ts` before retrieving the config value, ensuring sensitive fields are replaced with `__OPENCLAW_REDACTED__` sentinel values.
- Imported `redactConfigObject` from `../config/redact-snapshot.js` in `src/cli/config-cli.ts:4`
- Applied redaction to `snapshot.config` before `getAtPath()` in `runConfigGet()` at `src/cli/config-cli.ts:236-237`
- The redaction logic is well-tested and already used by the Web UI path and other config endpoints
- Sensitive field detection uses regex patterns matching `token`, `password`, `secret`, `apiKey` (with exceptions for fields like `maxTokens`)
- Non-sensitive paths return actual values unchanged
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is a targeted 2-line security patch that reuses existing, well-tested redaction infrastructure (`redactConfigObject()`) already used by the Web UI and gateway config endpoints. The change is minimal, focused, and follows established patterns in the codebase. The redaction function has comprehensive test coverage and handles edge cases (environment variable placeholders, whitelisted fields like `maxTokens`). No breaking changes or performance concerns.
- No files require special attention
<sub>Last reviewed commit: 92dace9</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11208: fix(config): prevent __OPENCLAW_REDACTED__ corruption on config writes
by janckerchen · 2026-02-07
85.4%
#12792: fix: exclude 'tokens' (plural) fields from config redaction
by jpaine · 2026-02-09
82.9%
#21901: fix: guard writeConfigFile against persisting redaction sentinels
by Protocol-zero-0 · 2026-02-20
82.0%
#16708: fix(security): OC-17 add token redaction to error formatting, depre...
by aether-ai-agent · 2026-02-15
78.9%
#22231: fix(security): redact sensitive data in session transcripts
by novalis133 · 2026-02-20
77.1%
#12296: security: persistence-only secret redaction for session transcripts
by akoscz · 2026-02-09
75.6%
#19115: fix(logging): improved redaction for config objects and unquoted keys
by Clawborn · 2026-02-17
75.6%
#21055: security(cli): gate systemPromptReport behind --debug flag
by richvincent · 2026-02-19
75.1%
#11663: fix: prevent config page header overlap with settings form
by shogunsea · 2026-02-08
74.7%
#15757: feat(security): add hardening gap audit checks
by saurabhsh5 · 2026-02-13
74.6%