Skip to content

Redact credentials in PR check summaries - #1284

Merged
mergify[bot] merged 4 commits into
mainfrom
lean178/1258-redact-validation
Nov 26, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
lean178/1258-redact-validation

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Redact credentials in PR check summaries

Context and goal

  • Goal: Keep recognizable credentials out of the generated PR Validation block.
  • Problem: Check commands from a private config can expose credentials to anyone who can read the pull request.
  • Context: PR creation and check refresh share the same Validation renderer.

Closes #1258

Acceptance

  • PR creation and refresh redact HTTP URL userinfo and Authorization values in synthetic commands.
  • Ordinary command text, recorded head, and exit codes remain readable. Execution and receipt matching use the original command.

Notes

The boundary is the GitHub Validation block. Private config and check receipts continue to supply original commands for execution and matching. Redact recognizable credential syntax at the shared renderer so the GitHub create and update payloads both use the safe text.

Both mocked GitHub payloads failed the regression on the unpatched base and passed with renderer redaction. Security review traced private config through receipt matching and both publication paths. The architecture guide still describes these boundaries.

The delta regression covers quoted header keys, shell-escaped values, and multi-part quoted headers. The focused tests pass at the approved head. The source head passed the full local gate after the cap increase. Integration with current main reaches 13,527 test lines against the 13,500-line cap, so this clean base merge is parked with its inherited delta approval.

Base

Base: 35f3d8d

Validation

Recorded for 84f75120e2fc

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Review

  • primary, claude, 8da5c4b, request_changes

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Architecture-Review: unchanged; the shared Validation renderer still projects local check receipts into the PR body.
Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca marked this pull request as draft November 26, 2026 01:18

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero primary review by claude on 8da5c4bcf55ed2b1d63d3bc85f0e57d4726e4c10, 47.8s: request_changes (0 critical, 1 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/github.py Resolved
Comment thread src/loopzero/github.py Outdated
def redact_credentials(value: str) -> str:
value = re.sub(r"""(?i)(https?://)[^\s/?#'"<>`]+@""", r"\1[REDACTED]@", value)
return re.sub(r"""(?i)((?P<quote>['"])?\bauthorization[ \t]*:[ \t]*)"""
r"""(?(quote)(?:(?!(?P=quote))[^\r\n])+|(?:(?:basic|bearer|token)\s+)?[^\s'"`]+)""",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Unquoted Authorization value leaks with shell-escaped spaces or unlisted schemes

In the unquoted branch, the optional scheme list is only basic|bearer|token, and [^\s'"]+` stops at the first whitespace. Two cases leak:

  • Shell-escaped spaces: -H Authorization:\ Bearer\ tok redacts only the backslash, giving Authorization:[REDACTED] Bearer\ tok.
  • Unlisted schemes: Authorization: Bot xyz, Digest ... and AWS4-HMAC-SHA256 Credential=... redact only the scheme word and leave the secret visible.

Safer default: in the unquoted branch, redact to the end of the shell word, treating \ as part of the word, or to the end of the line. Over-redacting is cheap here, while under-redacting publishes the secret.

Architecture-Review: unchanged; Validation rendering owns redaction for both GitHub publication paths.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero delta review by claude on aaa18e347b454d168dda834eeee7bfb380135617, 55.4s: approve (0 critical, 0 important, 3 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/github.py

def redact_credentials(value: str) -> str:
value = re.sub(r"""(?i)(https?://)[^\s/?#'"<>`]+@""", r"\1[REDACTED]@", value)
value = re.sub(r"""(?i)(\bauthorization(?:\\?['"])?[ \t]*:[ \t]*)(\\?['"])(?:(?!\2)(?:\\.|[^\\\r\n]))+\2""",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Quoted-key values that use a string prefix or = are still published unredacted

The new first pass only matches when a quote comes straight after the colon, and the second pass is skipped because of the quote after the key. So {"Authorization": f"Bearer <literal>"}, a b"..." or r"..." value, and dict(Authorization="Bearer <literal>") / Authorization="..." kwargs all reach the Validation block unredacted. The existing 'Authorization': '...' and "Authorization": "..." cases are covered. A literal token inside an f-string is unusual, so this is not blocking. If you want it covered, allow an optional [rbfu]{0,2} prefix before group 2 and accept [:=] as the separator. Add one test case for each.

Comment thread src/loopzero/github.py

def redact_credentials(value: str) -> str:
value = re.sub(r"""(?i)(https?://)[^\s/?#'"<>`]+@""", r"\1[REDACTED]@", value)
value = re.sub(r"""(?i)(\bauthorization(?:\\?['"])?[ \t]*:[ \t]*)(\\?['"])(?:(?!\2)(?:\\.|[^\\\r\n]))+\2""",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Two overlapping Authorization regexes need to be kept in sync by hand

Two passes now handle Authorization: one for a quoted key with a quoted value, and one for a quoted header string or an unquoted header. Each has its own escape and quote handling, so a future fix to one can easily miss the other. The ordering also matters: the second pass only avoids redacting "Authorization": "[REDACTED]" again because a quote sits between the key and the colon. Consider building both from one compiled, commented (re.X) pattern with named alternatives, or at least add a comment that explains why the order matters.

Comment thread src/loopzero/github.py
value = re.sub(r"""(?i)(\bauthorization(?:\\?['"])?[ \t]*:[ \t]*)(\\?['"])(?:(?!\2)(?:\\.|[^\\\r\n]))+\2""",
r"\1\2[REDACTED]\2", value)
return re.sub(r"""(?i)((?P<quote>['"])?\bauthorization[ \t]*:[ \t]*)"""
r"""(?(quote)(?:\\.|(?!(?P=quote))[^\\\r\n])+|(?:[a-z][\w-]*[ \t]+)?(?:\\.|[^\\\s'"`])+)""",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Broadened scheme prefix can over-redact ordinary command text

(?:[a-z][\w-]*[ \t]+)? now treats any word followed by a space as an auth scheme. For an unquoted Authorization:abc next-arg, both abc and next-arg (for example a following URL or flag) are swapped for [REDACTED]. Nothing leaks, but this works against the acceptance goal that ordinary command text stays readable. Low impact, because unquoted Authorization headers are rare in shell commands. You could keep the general scheme prefix only when another non-space token follows it on the same argument, or just accept the trade-off.

@eowca
eowca marked this pull request as ready for review November 26, 2026 02:46
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 5667a7b at 02:58 UTC

10 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:47 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1429
  • ✅ Merged 02:58 · 5667a7b · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 5667a7b into main Nov 26, 2026
11 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1258-redact-validation branch November 26, 2026 02:59
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.

security: Redact credentials in check commands published to PRs

1 participant