fix(sanitizer): redact PEM key bodies and no-prefix AWS secrets - #6678
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 28, 2026 02:09
bug-ops
force-pushed
the
fix/6592-pem-secret-scrubber
branch
from
July 28, 2026 02:09
0b60e3f to
15cd605
Compare
This was referenced Jul 28, 2026
bug-ops
force-pushed
the
fix/6592-pem-secret-scrubber
branch
from
July 28, 2026 11:36
15cd605 to
6dc6da1
Compare
This was referenced Jul 28, 2026
scrub_secret_shapes and its consumers missed PEM private-key bodies and raw AWS secret access keys: no existing pattern spanned a PEM key's multi-line body, since the -----BEGIN prefix entry only ever matched a single-line token. Add bounded PEM (terminated + unterminated-fallback) and context-anchored AWS-secret detectors to zeph-common, wire them into zeph-sanitizer, zeph-core's transitive redact_secrets, and zeph-memory's previously non-PEM-aware compression_guidelines. The subagent live-transcript streaming path needed a dedicated fix: its fixed-size holdback window could split a PEM header and footer across separately-sanitized deltas, letting an unmarked middle slice of key body through. The holdback now widens for an unterminated header and extends past an already-closed block's footer so the whole span always flushes as one unit. Closes #6592
bug-ops
force-pushed
the
fix/6592-pem-secret-scrubber
branch
from
July 28, 2026 12:21
6dc6da1 to
d391bd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scrub_secret_shapesand its consumers missed PEM private-key bodies and raw (no-prefix) AWS secret access keys. No existing pattern spanned a PEM key's multi-line body at all, since the-----BEGINentry inSECRET_PREFIXESonly ever matches a literal single-line token.PEM_PRIVATE_KEY_PATTERN(multi-line, bounded, covers RSA/EC/DSA/OPENSSH/ENCRYPTED/PGP-block/RFC4716-SSH2 label variants) and aPEM_PRIVATE_KEY_UNTERMINATED_PATTERNfallback for footerless/truncated headers, tozeph_common::secrets.zeph-sanitizer::scrub_secret_shapes,zeph-core::redact::redact_secrets(transitively), andzeph-memory::compression_guidelines::redact_sensitive(previously not PEM-aware at all).zeph-subagent's live-transcript streaming path (forward.rs): its fixed-size holdback window could split a PEM header/footer across separately-sanitized deltas, letting an unmarked middle slice of key body through. The holdback now widens for an unterminated header and extends past an already-closed block's footer, so a whole PEM span always flushes as one contiguous unit.AWS_SECRET_KEY_PATTERN, a context-anchored heuristic that only flags a 40+ char base64-ish run when immediately preceded by an AWS-secret-style marker (aws_secret_access_key,secret_access_key,aws_session_token, etc., tolerant of separator style, so it also matches camelCase JSON keys likeSecretAccessKey/SessionToken).Closes #6592
Review process
This went through 4 rounds of developer/adversarial-critic iteration before code review:
Code review then caught two additional CI-gate issues none of the four rounds had checked (a broken rustdoc intra-doc link, and 12
gitleakshits on the new PEM-shaped test fixtures) plus one doc-wording nit, all fixed in a follow-up round and re-verified.Two minor tradeoffs are accepted and documented in-code rather than fixed, per team discretion during review:
-----BEGINwith no footer yet holds back up to 8,192 bytes in the live transcript with no status indicator (delayed, never dropped).Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings— cleancargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins— 15174/15177 passed; the 3 failures are pre-existing wall-clock concurrency-timing tests in files this diff does not touch, reproduced independently under confirmed heavy concurrent build load on this machine (uptimeload average ~126)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"— cleancargo test --doc --workspace --features "desktop,ide,server,chat,pdf,scheduler"— all passinggitleaks protect --staged— clean (added scoped allowlist entries for the new fake PEM/AWS test fixtures, matched on fixture-body content rather than path, so real secrets in these files would still be caught)-----BEGINsplit across deltas), multibyte (CJK) input near a holdback boundary, AWS true/false positives, and prose-survival around a truncated PEM mention