Repository navigation
feat(security): add structured credential detectors behind an internal switch - #29369
Conversation
Sensitive change review
|
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: with the switch off, the redaction path behaves as it does on main, and removing Notes
[DESIGN-REVIEWED] b828241 Description read[DESCRIPTION-READ] c3bc7f219032ea097fd2e08f69780507dce4d9ddc6da9c7c19b7bba05bb8674e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks, because the code is dormant and easy to remove. But even with the switch on, this wiring cannot deliver the harm the Goal names, since pass 1 still redacts key IDs. Notes
What this change shipsInventory (6 items) — 3 justifiedIntent: stage a credential classifier that knows a value's capability, behind a switch that is off, as the first phase of #22552. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] b828241 Description read[DESCRIPTION-READ] e8d457f703b0d61a2c1c4a4d4dc4a77ae499ea3b6babe8c73e307bd6071b15d8 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: This PR deletes the unused TIGHTENING: structured credential detectors placed in front of the redaction credential plan -- credentials that the fixed patterns miss leaking through redacted output. The hunk is in ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: Rows are written for posix, windows and any. The diff assumes no path separator, interpreter or environment-variable spelling, so the platform rows only probe the exfil tier, which calls
No platform the diff assumes is left without a row. UNADJUDICATED:
[SCOPE-REVIEWED] b828241 |
Sensitive change review
|
bolichen97
left a comment
There was a problem hiding this comment.
This looks good to me at 37ea136, and I would approve it, but it now conflicts with main. Please rebase and I will approve the new head.
What I checked, since this touches the credential redactor every surface uses:
- The switch is off and nothing outside code turns it on.
compat.use_rule_table()routes the credential plan's first pass to the table; with it off,_credential_redaction_planruns_pattern_passand then_later_passes, which is the old body split in two with no change to either half. - The stream redactor is unchanged while the switch is off.
StreamRedactornow callsredaction_rules.streamon every chunk, so I read each call.read_bufferreturns the empty result whentable_active()is None, andkeep_pairs/floor_past_pairsthen return the cut unchanged, sotable.openandtable.strongare empty and the discard and hold logic takes the old branches.redact_windowadds no prefix when the table is off.discard_run_resanddiscard_carryare not gated, but every kind they add is namedtable-*, so they cannot replace the four legacy discard patterns or change a legacy carry.line_contextonly tracks the current line. - Small side effects:
rules_version()now hashestable=0, so the display verdict version changes once on upgrade; the newredaction_unavailabletier and its empty-value record are reached only through the table path.
All 100 checks are green, including the Security Scope Review, the redaction property and parity tests, and the regex linearity check.
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes at 37ea136. This replaces my earlier comment that said I would approve after a rebase.
The maintainers have adopted a rule that we do not approve a change whose solution relies on adding or widening regex matching to redact secrets, scan output, or build rules; we ask for a structured approach instead. The credential rule table is built that way: its detection is new regex throughout, with about 22 new pattern: entries in security/redaction_rules/rules.yaml and new compiled patterns in redaction_rules/detectors.py, redaction_rules/stream.py and redaction_rules/compat.py. Shipping it behind a switch that is off does not change that, since the table is the design the later change turns on.
Please either move detection to a structured design, for example exact key matching on known field names (the AccessKeyId / SecretAccessKey style labels the table already keys on), a typed scanner that tokenises the text and classifies whole tokens by their known formats, or parsing the structured inputs (JSON, headers, query strings) and judging values by key; or raise the approach with the maintainers first, so the rule table's design can be agreed before more of it lands.
What I checked before and still holds: with the switch off, the credential plan and the stream redactor take the same path as main, and no config, start step or dashboard path turns the switch on. The PR also conflicts with main now.
|
@bolichen97 thanks. Before I push more code, here is the structured design I plan to put in this PR and the follow-up. Your rule, as you stated it:
Detection, with no regex and no entropyNothing in the new package imports
Measured against mainThese are local corpora rebuilt from the earlier experiments: a 9,000-case labelled synthetic set (the first four rows), 611 benign prose records, and a reconstruction of your 52-case simulation. 31 of those 52 cases are my guesses, since the review gave totals, so please share the originals if you can.
Not changedThe exfiltration URL check is not changed, so Crew-built sign-in links are still removed whole, as on main. Making that check remove only the parameter it objects to needs its own proposal, and I'd raise it separately. Plan for the two PRsI'd rebuild both PRs in place:
Questions for the maintainers
|
37ea136 to
c63020d
Compare
Sensitive change review
Written by the Crew Tasks Bot on behalf of mbriones98. |
72779a5 to
12d7b05
Compare
Sensitive change review
Written by the Crew Tasks Bot on behalf of mbriones98. |
Sensitive change review
Written by the Crew Tasks Bot on behalf of mbriones98. |
aa31d97 to
4a1932d
Compare
Sensitive change review
Written by the Crew Tasks Bot on behalf of mbriones98. |
…l switch Add `security/redaction_structured/`, credential detectors built from structure only: no regular expressions and no randomness or character-mix scores. A source test holds the package to both. Rules are data in `table.ROWS` (names, literal prefixes, alphabets, lengths, checksum ids) and the loader refuses a `pattern` field. - `tokens.py` reads a token from its literal anchor over its format's alphabet and checks its length, fixed structure and vendor checksum (GitHub CRC32). A JWT or JWE header must decode to JSON naming `alg` or `enc`. A 40- or 64-character lowercase hex value is a git object name and is never a Secret. - `armour.py` reads PEM and PGP private-key blocks by their BEGIN/END lines. - `known_key.py` reads the four AWS secret key names in JSON, assignments, CLI flags and XML, with a value-shape check. - `identifiers.py` parses a URL query per RFC 3986 and replaces only the values of six OAuth keys. It and `identifier_values.py` mark values that stay visible. - Every unit has a size bound and fails closed past it, so `stream.py` gives the whole-text result for any split. A run of mask letters longer than a masked value is decided at once and never held. - A URL longer than the URL row's 4096-character bound is not read as a URL, so its query values are left to the credential passes that run after the detectors. `compat.py` is the seam the credential plan reads. Its switch, `compat.use_rule_table()`, is off and has no user setting. Off, the plan is pass 1 then passes 2-4, as before. On, the detectors read the text first, their Secret hits are replaced by the credential tag, the four passes run on that text, and the spans are moved back and merged. A detector error replaces the whole text, logs the error type and counts one metric. `StreamRedactor` asks the seam where to hold a buffer. The display verdict version keys the switch value. Remove `security/redaction_rules/` and its tests, so `table.ROWS` is the only credential table. Nothing called it: no seam, gateway step or user setting read it. With the switch on, only a unit the detectors are still deciding (an open unit, or a hit the cut would split) lowers the stream holdback floor, and only to the detectors' own cut. `StreamRead.undecided` says which. A long run with no anchor now keeps the 512-character bound instead of being held until flush. This commit folds the earlier merges of main into one commit on current main. The package line budget in test_security_gate_liveness.py keeps main's raise notes and is the re-measured size, 35,533 lines.
4a1932d to
b828241
Compare
Sensitive change review
Written by the Crew Tasks Bot on behalf of mbriones98. |
Problem / Motivation
Goal: Put the credential rule table and its wiring in place behind an internal switch that is off and has no user setting yet, so the table can be finished and checked before anyone can turn it on.
The rule table under
security/redaction_rules/classifies each value by what it can do (Secret, Bearer link, Identifier), as the recorded decisiondocs/decisions/2026-10-20-redaction-classifies-by-what-a-value-can-do.mdsets out. No surface calls it yet: every surface runs the legacy fixed-pattern pass, which redacts an AWS access key ID as if it were a secret.Why it matters
People reading CloudTrail and service logs through Kiro Crew lose the key ID, the one value that joins a log row to the access key that made the call. A key ID cannot authenticate by itself. This is the first step of the #22552 phase that routes redaction through the table. Shipping it dormant keeps this change small and leaves behaviour exactly as it is today; the user setting arrives in a later change, once the table is ready to be turned on.
Not a goal
token=parameter pass). They run unchanged either way.What changed (motivation → approach → change)
Review asked for a structured approach in place of new or wider regex matching. This PR therefore no longer adds regex rows: it adds credential detectors built from structure only, behind the same internal switch, which stays off with no user setting. Main's
redaction_rules/package and its passes are not changed.Location. The detectors are a new package,
src/kiro_crew/security/redaction_structured/, wired behind the switch. Main's unusedredaction_rules/package and its tests are removed, sotable.ROWSis the only credential table. Nothing called that package, so the switch-off path still runs exactly the code main runs.No regex, no randomness scores. The package imports neither
renorregexand has no randomness or character-mix scoring; a source test holds it to both. Rules are data intable.ROWS: names, literal prefixes, alphabets, lengths and checksum ids. The loader refuses apatternfield.tokens.py,armour.pystr.find) over its format's alphabet, with its length, fixed structure and vendor checksum (GitHub CRC32) checked; a JWT/JWE header must decode to JSON namingalgorenc. A 40- or 64-character lowercase hex value is a git object name and is never a Secret; an exact AWS label still wins over it. PEM and PGP private-key blocks are read by their BEGIN/END lines.known_key.py,identifiers.pyaws_secret_access_key,SecretAccessKey,aws_session_token,SessionToken) in JSON, assignments, CLI flags and XML, with a value-shape check. A URL query is parsed per RFC 3986 and only the values ofclient_secret,access_token,refresh_token,id_token,code_verifierandpasswordare replaced.identifier_values.pystream.py,engine.py,model.py,charsets.py,checks.py,table.pycompat.pycompat.use_rule_table(), set only by code (publish_use_rule_table). Off: the credential plan is pass 1 then passes 2-4, as on main. On: the detectors read the text first, their Secret hits are replaced by the credential tag, the four passes run on that text, and the spans are moved back and merged. A detector error replaces the whole text, logs the error type and counts one metric.security/redaction.py_pattern_pass) from passes 2-4 so the detectors can run in front of them, and routes the plan by the switch.security/text_redaction.pyStreamRedactorasks the seam where to hold a buffer, and drops a unit decided while still running. Both do nothing while the switch is off.credential_patterns.py,dashboard/display_verdicts.pyredaction_unavailable) gets its Secret tier; cached display verdicts are keyed on the switch (table=0while off).Documented bound. A URL longer than the URL row's 4,096-character bound is not read as a URL by the detectors, so its query values are left to main's credential passes, which run after the detectors and still remove them. A run of mask letters longer than a masked value is decided at once and never held.
docs/system-specs/modules/security.mddescribes the package, the seam and the switch.Backwards compatibility
Compatible: the switch is off and no user can turn it on, so redaction output is unchanged; the redaction entry points keep their signatures, plan shape and rule names. No config key is added. Cached display verdicts are recomputed once, because their version now includes the switch value.
The diff removes
src/kiro_crew/security/redaction_rules/andtest/test_redaction_rules.py. Its readers on main:Reader: setup.cfg:package_data -- release -- the
rules.yamlpackage-data line is removed with the packageReader: scripts/ci_file_shard_pins.txt:test_redaction_rules.py -- release -- the pin for the deleted test file is removed; test_ci_file_shards.py reads the pins
Reader: docs/system-specs/modules/security.md:redaction_rules -- release -- the package's entry is removed
No other module, entry point or app imports it.
Tests
test_redaction_structured.py,_git_oauth.py,_identifiers.py,_protect.py,_stream.pycover each detector, the source test (nore/regeximport, no randomness or character-mix terms, with self-tests), the six OAuth keys, the AWS label over the git object-name row, and stream-equals-whole-text at every split.assert_linear_work), never by timing, over adversarial inputs including repeated mask runs; a stream fed mask runs in pieces keeps its pending text bounded.test_stream_table_parity.pyandtest_redaction_compat_property.pyturn the switch on through a fixture; one test checks that off runs main's plan.redaction.pyandtext_redaction.py; the new subpackage is not counted), and the regex-linearity check, which now reads the split-out pass 1.scripts/run_scoped_tests.py --surface backend) is listed below.Scoped backend run (4,437 related test files, all 8 batches): 298 test ids failed; each also fails on a clean
origin/mainworktree at the base this was measured on in the same environment (289 in a parallel re-run of the failing files, the other 9 when run one at a time), so none come from this change.Proof: not provable -- other: a feat change behind an internal switch that is off and has no user setting; its tests run the detectors with the switch on
Manual verification
N/A — unit coverage sufficient: the change is pure text processing behind an internal switch that is off.
Related Issues
Part of #22552
Follow-up: #31895 (one owner setting that turns credential redaction off on every path)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Known follow-ups