Skip to content

Redact forwarded credentials from check diagnostics - #1745

Merged
mergify[bot] merged 4 commits into
mainfrom
lean178/1250-redact-check-diagnostics
Nov 26, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
lean178/1250-redact-check-diagnostics

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Redact forwarded credentials from check diagnostics

Context and goal

  • Goal: Keep forwarded check credentials out of terminal diagnostics and receipts.
  • Problem: Stage output can copy environment secrets into retained diagnostic tails.
  • Context: Scrub effective wrapper and stage values at the existing diagnostic boundary. Preserve stage execution, result codes, and cache reuse.

Closes #1250

Acceptance

  • Local forwarded secrets and configured stage secrets reach their stages and are redacted in retained and displayed diagnostics.
  • Success, failure, and timeout keep existing verdicts and tail limits. Preserve ordinary diagnostic text.
  • An old cached tail is scrubbed before reuse.

Base

Base: aa563c2

Notes

Carries forward the reviewed redaction idea from #1414. The check and runner receive their normal environment. The redaction runs on diagnostic text before it is retained, including timeout and old cached tails.

Validation

Recorded for ee665d210434

  • 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

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

Review

Architecture-Review: unchanged; check environments and outcomes retain their existing authority while captured diagnostics redact forwarded values.
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 primary review by claude on 581c25e6a944c5f4850bc9b337dd4df0ecfa905a, 70.7s: 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/sandbox.py
normalized = value.strip()
if not normalized:
return False
if _CREDENTIAL_ENV.search(name):

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: Credential-named variables with very short values remove ordinary text everywhere

_private_check_value treats any non-empty value as secret when the variable name matches _CREDENTIAL_ENV, however short the value is. The test even expects the 3-character value p1n to be redacted. If a project forwards a credential-named flag such as DISABLE_AUTH=1, SKIP_AUTH=true or HF_HUB_DISABLE_TOKEN=1, _redact_check_output replaces every 1 or true in the stage output. That mangles line numbers, counts and messages like tests/x.py:[REDACTED]2, which goes against the acceptance criterion "Preserve ordinary diagnostic text". Smallest fix: skip trivial values in the credential branch too, such as a minimum length of about 3–4 characters plus a check that excludes plain numbers and booleans.

Comment thread src/loopzero/sandbox.py
if _CREDENTIAL_ENV.search(name):
return True
mode = name == "ENV" or name.endswith(("_ENV", "_ENVIRONMENT", "_MODE"))
return len(normalized) >= 6 and not (mode and normalized.casefold() in _CHECK_MODES)

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: Every forwarded value of 6+ characters is redacted, including paths and usernames

Any variable outside _CHECK_CONTEXT_ENV whose value has at least 6 characters is treated as a secret. Common allowlisted or configured variables hold paths or identities, such as USER, CARGO_HOME, GOPATH, JAVA_HOME, VIRTUAL_ENV, PYTHONPATH and SHELL=/bin/bash. Their values then get replaced inside tracebacks and compiler errors. For example, with USER=marcin allowlisted, the worktree path becomes /home/[REDACTED]/.... Verdicts are unaffected, but diagnostics become harder to use. Consider not redacting values that are absolute paths, or names ending in _HOME, _PATH or _DIR, in the non-credential branch. Alternatively, document the trade-off and test a path-valued variable so the behavior is intentional.

Comment thread src/loopzero/sandbox.py
return CheckResult(command, TIMEOUT_EXIT, timeout,
_check_tail(exc.stdout + f"\n[loopzero] timed out after {timeout:g}s"))
return CheckResult(command, done.exit_code, done.duration_s, _check_tail(done.stdout))
_check_tail(exc.stdout, config, suffix=f"\n[loopzero] timed out after {timeout:g}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: Redaction happens after _proc.run has already cut the output, so part of a secret can survive

_run_one passes tail_chars=CHECK_TAIL_BYTES to _proc.run, so the output is cut to its last 16K characters before _check_tail redacts it. If a secret straddles that cut, the remaining fragment no longer matches the full value and is kept. This shows up in the retained tail when the output is long but has few lines (single-line or minified output), because _proc.tail then keeps that first line. The same applies to runner-provided frame["tail"] and the ProcTimeout.stdout paths. Smallest fix: before redacting, drop the first partial line (or the first max(len(secret)) characters) of a tail that was cut, or redact any secret prefix found at the very start of the text.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

waits for test headroom after #1663

@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 ee665d210434e8e909f2ae602b5489eee345c63e, 20.9s: approve (0 critical, 0 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/sandbox.py
def _runner_environment(config: Config) -> dict[str, str]:
return {**SANDBOX_ENV, **dict(config.env)}


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: Extra blank line left from conflict resolution

The merge kept the + blank line from the conflict block, so _runner_environment and check_environment are now separated by three blank lines instead of two. The ruff config doesn't select E3, so lint still passes and nothing changes at runtime. To fix, delete the extra blank line.

@eowca
eowca marked this pull request as ready for review November 26, 2026 13:52
@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 a472c8f at 13:58 UTC

4 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 13:53 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1915
  • ✅ Merged 13:58 · a472c8f · 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

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit a472c8f into main Nov 26, 2026
16 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1250-redact-check-diagnostics branch November 26, 2026 13: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 forwarded secrets from check logs and receipts

1 participant