Repository navigation
Harden sensitive output boundaries for CodeQL - #74
Conversation
Separate benign redaction helpers and approval metadata from names that CodeQL classifies as sensitive sources, while keeping compatibility aliases for the public helpers. Also reduce incidental disclosure in doctor, guard test, receipt writing, and server startup output, and cover those boundaries with regression tests. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Capy couldn't review this pull request because Cojo's workspace is out of credits, add credits or enable auto-reload to resume automatic reviews. The code reviews included with your plan this billing period are used up, so reviews are paid from your credits until the plan resets. A Low or Medium effort review counts as 1 included review, and a High effort review counts as 2. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| def _write_stdout(text: str) -> None: | ||
| """Receipts are UTF-8 documents, whatever the console encoding (cp1252 on Windows).""" | ||
| buffer = getattr(sys.stdout, "buffer", None) | ||
| safe_text = redact(text) |
There was a problem hiding this comment.
🔴 Malformed JSON receipts and diagnostics
With a prompt like TOKEN=dev01" suffix", redact removes the backslash that escapes the quote in JSON. Receipt generation reports success, but JSON parsers reject the output. The stats, doctor, and guard commands apply the same redaction to serialized JSON.
Learn more
redact_run masks receipt text before rendering, and to_dict includes the original prompt text in the receipt. JSON serialization inserts a backslash before a literal double quote. The unquoted assignment pattern counts that backslash as part of the value, so a five-character value with a digit becomes a six-character match. When the replacement removes the backslash, the quote ends the JSON string early. The same order applies to receipt file output, stats JSON, doctor and guard status, and guard test. A serialized newline can also be consumed with adjacent text without making the JSON invalid.
Example: Generate a JSON receipt for a session whose prompt says Document why TOKEN=dev01" suffix" is valid shell syntax. The command exits zero, but json.loads rejects the output because the quote after [REDACTED] is no longer escaped.
Recommended fix: Apply redaction to display fields before serialization or markup escaping. Keep the final writer format-neutral, and redact any additional stats, doctor, and guard-test fields on their structured objects before json.dumps. Add a JSON-parsing regression test using a literal quote after a short assignment, covering both receipt destinations.
Was this helpful? React with 👍 or 👎 to provide feedback.
CodeQL follows the synthetic test value into the stdout boundary when the test variable itself is named as a secret. Use a neutral fixture name; the tested redaction behavior is unchanged. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Cover short URL userinfo passwords and common query credential parameters, keep the default approval key variable visible while hiding custom names, remove a stale import, and align the security documentation with the minimized output. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| r"([?&](?:api[_-]?key|access[_-]?token|auth[_-]?token|token|client_secret|password|secret" | ||
| r"|key|sig|signature|x-amz-signature)=)" |
There was a problem hiding this comment.
🟡 Guard blocks writes with public lookup keys
_QUERY_REDACTION_RE treats a lookup like ?key=checkout.title as an access token. assess_step reports a hardcoded secret, so the default guard policy blocks the write.
Learn more
The output masker and the write risk scanner share the query rule. redaction_kinds accepts a match as an access token unless it looks like a placeholder or already matches a known token format. assess_step turns that label into secret_in_content, which the default deny policy blocks before the agent writes the file.
Example: A Claude Code Write call saves const endpoint = "/api/translations?key=checkout.title";. The default guard denies it as a hardcoded access token, even though checkout.title only identifies a translation string.
Recommended fix: Give redaction_kinds a stricter query rule than redact_text. Keep conservative output masking, but require recognizable credential formats or provider-specific context before treating generic key, sig, or signature values as hardcoded secrets. Add a guard test that permits the translation lookup alongside the existing redaction tests.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Test plan
Generated with Devin