← Back to PRs

#21055: security(cli): gate systemPromptReport behind --debug flag

by richvincent open 2026-02-19 16:05 View on GitHub →
cli commands size: XS
## Summary - **Problem**: `openclaw agent --json` includes the full `systemPromptReport` in output, leaking internal tool schemas, provider configurations, and platform details to logs/pipelines. - **Impact**: LOW severity (CVSS 3.0) — information disclosure; increases attack surface for prompt injection and privilege escalation. - **Solution**: Filter `systemPromptReport` from default `--json` output; expose only under `--debug` flag. ## Change Type - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Docs - [x] Security hardening - [ ] Chore/infra ## Scope - [ ] Gateway / orchestration - [ ] Skills / tool execution - [ ] Auth / tokens - [ ] Memory / storage - [ ] Integrations - [ ] API / contracts - [x] UI / DX - [ ] CI/CD / infra ## Solution Details ### Changes - Added `--debug` flag to `openclaw agent` command (`src/cli/program/register.agent.ts`) - Updated `delivery.ts` to strip `systemPromptReport` from `meta` unless `opts.debug` is true - Added `debug?: boolean` to `AgentCommandOpts` type (`src/commands/agent/types.ts`) - No change to non-JSON output modes ### Usage ```bash # Default --json: systemPromptReport excluded openclaw agent --json -m "test" # With --debug: systemPromptReport included openclaw agent --json --debug -m "test" ``` ### Example Filtered Content Before (default `--json`): ```json { "systemPromptReport": { "tools": ["bash", "read", "write", "web_fetch"], "models": { ... }, "provider": "anthropic" } } ``` After (default `--json`): ```json {} ``` Only visible with `--json --debug`. ## Security Impact - New permissions/capabilities? No - Secrets/tokens handling changed? No - New/changed network calls? No - Command/tool execution surface changed? No - Data access scope changed? No - **Benefit**: Reduces information disclosure in logs; limits attack surface for prompt injection ## User-visible / Behavior Changes - `systemPromptReport` no longer included in `--json` output by default - Developers debugging agents can use `--debug` to restore full output - No change to interactive/pretty-print modes ## Compatibility / Migration - Backward compatible? Yes — adds optional flag, changes default behavior - Config/env changes? No - Migration needed? No - **Breaking change**: Pipelines relying on `systemPromptReport` in `--json` output must add `--debug` flag ## Risks and Mitigations - **Risk**: Existing automation/scripts expect `systemPromptReport` in `--json` output - **Mitigation**: Clear migration path via `--debug` flag; field is undocumented/internal - **Risk**: Users debugging issues may not know about `--debug` flag - **Mitigation**: Help text documents the flag; error messages can suggest it when relevant ## Evidence - [x] Verified `openclaw agent --json` excludes `systemPromptReport` - [x] Verified `openclaw agent --json --debug` includes `systemPromptReport` - [x] Full test suite passes (6,718/6,728) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds `--debug` flag to gate `systemPromptReport` output in `openclaw agent --json`, reducing information disclosure in logs and pipelines. **Key changes:** - Added `--debug` CLI flag to `register.agent.ts` - Filters `systemPromptReport` from JSON output in `delivery.ts` unless `--debug` is set - Added `debug?: boolean` type to `AgentCommandOpts` **Issues found:** - **Critical logic bug**: `filteredMeta` is scoped to the `if (opts.json)` block, causing `systemPromptReport` to leak in two return paths (lines 166 and 207) that return the unfiltered `result.meta` - The security filtering is bypassed when: (1) no payloads exist, or (2) `--json --deliver` are both used - This undermines the PR's security goal of preventing information disclosure <h3>Confidence Score: 1/5</h3> - This PR contains a critical security bug that undermines its stated security objective - The implementation has a variable scoping issue where `filteredMeta` is only accessible within the `if (opts.json)` block, causing two return paths to bypass the security filtering entirely. This defeats the purpose of the PR, which is to prevent `systemPromptReport` leakage. The bug will cause sensitive data to leak when either no payloads exist OR when both `--json` and `--deliver` flags are used together. - src/commands/agent/delivery.ts requires immediate attention - the filtering logic must be refactored to apply to all return paths <sub>Last reviewed commit: 5b510c2</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs