Skip to content

Harden sensitive output boundaries for CodeQL - #74

Merged
kodji7202-code merged 3 commits into
mainfrom
devin/codeql-sensitive-output-hardening
Nov 26, 2026
Merged

kodji7202-code merged 3 commits into
mainfrom
devin/codeql-sensitive-output-hardening

Conversation

@kodji7202-code

@kodji7202-code kodji7202-code commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • rename internal redaction helpers and approval metadata so CodeQL no longer treats benign redacted values as sensitive sources
  • keep compatibility aliases for existing public helpers
  • redact approval server URLs, receipt stdout/file output, doctor output, and guard test output at their final boundaries
  • hide custom approval key variable names and trusted proxy network details in user-facing output
  • close redactor gaps for short URL userinfo passwords and common query credential parameters
  • align doctor/serve security documentation with the minimized output
  • add regression tests for receipt, doctor, guard, URL, and query redaction

Test plan

  • python -m ruff check runledger tests
  • python -m mypy runledger/paths.py runledger/_text.py runledger/jsonl.py runledger/ai_defaults.py runledger/userconfig.py
  • python -m compileall -q runledger
  • python tools/check_conformance.py
  • targeted redaction/doctor/guard/receipt tests
  • full local suite before the final review patch: 4450 passed, 32 skipped; 2 pre-existing stats cache failures reproduced on clean HEAD in this Windows environment
  • final targeted review-patch validation: 23 passed

Generated with Devin

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-ai

capy-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

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.

Open in Capy

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T17:38:20.644136Z cab9568 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Devin Review

Comment thread runledger/cli.py
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

github-advanced-security[bot]

This comment was marked as resolved.

kodji7202-code and others added 2 commits November 26, 2026 19:52
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>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread runledger/secrets.py
Comment on lines +105 to +106
r"([?&](?:api[_-]?key|access[_-]?token|auth[_-]?token|token|client_secret|password|secret"
r"|key|sig|signature|x-amz-signature)=)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@kodji7202-code
kodji7202-code merged commit 63e3e27 into main Nov 26, 2026
25 checks passed
@kodji7202-code
kodji7202-code deleted the devin/codeql-sensitive-output-hardening branch November 26, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants