Repository navigation
fix(security): hold a streamed AWS key-value pair past the 512 floor - #21573
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The stream redactor keeps growing its own carrier state machine; the description's own fuzz says it still leaks in 295 of 4,000 cases where batch redacts. Watch
Suggestions
[DESIGN-REVIEWED] ffb262b Description read[DESCRIPTION-READ] ea3e1a28fe1367be722cc37e2dc83abfb10a8a44a65e6ef52a4c8cd15416602f 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 Check that the 295 fuzz cases the description says still leak on this branch all fall under the listed Not-a-goal shapes, not a new one. What this change shipsInventory (10 items) — 10 justifiedIntent: stop a streamed AWS secret longer than 512 characters, sent after its key, from reaching dashboard and channel viewers unredacted. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] ffb262b Description read[DESCRIPTION-READ] 1612f1e8a6dc17df43e9bc7a0b7c2c72213448eef9f4b53367e0e762915bf9a6 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 -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: ADJUDICATED: 15 candidates, verdicts pending from the harness. The diff does not touch the tool-call deny composite. PLATFORM COVERAGE: posix rows: the test runs, UNADJUDICATED: The guard is
These are narrowings I can argue but not confirm. The narrow fix to consider is letting the AWS cut also land at a JSON structural delimiter ( [SCOPE-REVIEWED] ffb262b |
32eb180 to
e62eec0
Compare
|
span=9d6bc76fed0d
|
|
note: Security Scope CONCERNS at 32eb180 (0 confirmed newly refused) -- answered per candidate
|
e62eec0 to
d21134a
Compare
|
span=9c8352609526
|
|
span=fc6840566455
|
|
span=d9b8507e79b5
|
|
span=2ebd0260e8b7
|
d21134a to
9eb30f6
Compare
|
[operator: bolichen97] Rebased onto main d32ab41 (d21134a -> 9eb30f6), still one commit. Main moved |
|
[operator: bolichen97] Maintainer ruling: redesign the AWS stream cut rule. The cut lands only at whitespace or at the start of the held buffer, and never inside a batch credential match. The URL walk-back, the ceiling clamp (the "cut raise" toward main's 512 floor) and the padded-label states ( 57b1348 -> 65a6afe, still one commit, rebased onto main 8f828d6 (main did not touch this PR's files). Tests flipped or removed by this ruling, each with its reason:
Local GPT and Opus reviews of the intermediate commit each found one real leak vs main, both fixed in this head with tests: a batch match that starts mid-token now walks the cut back to whitespace (a bare run glued before |
|
span=8c954628938f
|
|
span=29afcaa962ab
|
|
span=e788b93c0032
|
|
checked: per-chunk cost while an AWS label is held
|
Sensitive change review
|
|
span=8c954628938f
|
|
span=87dae0dc8f33
|
|
span=b1b72a437697
|
|
span=14b187533989
|
|
span=34346eb20bd5
|
Sensitive change review
|
|
[operator: bolichen97] 65a6afe -> ceb4d5f, still one commit, rebased onto main 2501be6 (main did not touch this PR's files). Fixes the GPT and Opus blocks on 65a6afe: label back-off, the carried tail and the glued-label stop run only for an AWS-only discard, a name needs its separator, and with no AWS carrier one discard kind is armed as on main (3,000 seeded no-AWS streams byte-identical to main). Dispositions posted per lane; Sensitive Change template reposted for ceb4d5f. |
A value after a recognised AWS key label (aws_secret_access_key=, "SessionToken": ", ...) is only redacted while its label reaches the same batch call. Past the 512-character stream floor the stream redactor cut such a value from its label and streamed it raw. A label that has reached its separator is now a strong anchor, like Bearer: the value is held up to the JWT ceiling and fails closed beyond it. The cut lands only at whitespace, at the start of the held buffer or at the start of a batch match, so a whitespace-free run that carries the label past the ceiling is dropped whole. Closes #17115
|
span=8c954628938f
|
|
checked: the fuzz note on what still leaks here and not on main
|
|
checked: the recorded decision is the linked issue's
|
|
[operator: bolichen97] ceb4d5f -> ffb262b, still one commit, rebased onto main 5c17469 (main did not touch this PR's files). Fixes the GPT block on ceb4d5f: the PEM guard covers a closed AWS pair as well as an open one. Sensitive Change template reposted for ffb262b. Security scope candidate validation was red on ceb4d5f at "Probe the candidate set for credential shapes": the scope lane's own generated candidate set carried a credential shape. No file in this diff is part of that set; it reruns on this head. |
Sensitive change review
|
|
span=e5907619c682
|
|
span=80bc8a57e4a2
|
|
checked: the 295 remaining fuzz leaks fall in known, main-shared shapes
|
chenmingwei23
left a comment
There was a problem hiding this comment.
Approved: lanes green on this head, no outstanding reviewer blockers.
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Review lanes on the head carry CONCERNS (advisory) and no BLOCK; the watch holder read them and approved explicitly.
Problem / Motivation
Goal: A streamed AWS secret after its key (
aws_secret_access_key=,"SessionToken": ", ...) never reaches the chat stream raw, however long it is.The batch pass redacts an AWS key-value pair only when the key and the value sit in the same
redact()call. The stream redactor holds back at most 512 characters for a value with no known anchor. A longer value was cut at 512, cut away from its key, and streamed raw.Measured on
origin/main8c4a3d9bcewith a value that has no 40-character base64 run (so only the key-value branch can catch it): at chunk sizes 1, 7, 64 and 600, a 600 to 5,000 character value streamed with every 10-character piece of it visible, for all four AWS key shapes (key=v,key = "v", JSON"Key": "v",Key: v). 73 of the 125 tested cases leaked. The batch pass redacted every one of them whole.Why it matters
An AWS session token is often longer than 512 characters, and it is a working credential until it expires. The live stream goes to every open dashboard tab and to channel adapters, so a model that echoes a credentials file or a
SessionTokenfield shows the token to anyone watching the stream.Not a goal
api_key=,password:and so on). Those have no batch key-value rule today."SessionToken" : "v"). That split exists for short values too.Key+ long padding +: vsplit in that padding can still streamv, exactly as main does.What changed (motivation → approach → change)
Symptom: a long AWS value streams raw after the first 512 held characters. Root cause: the stream redactor only raises its holdback for STRONG anchors (a JWT, a
Bearerheader, a?token=parameter). An AWS key label was not one, so the 512 floor cut the value away from its key.Approach, as the issue's recorded decision says: hold past the floor up to the existing 4,096 ceiling, and fail closed beyond it.
StreamRedactor.feedinsrc/kiro_crew/security/text_redaction.pygets an AWS key-value anchor beside the Bearer one. The label grammar and its linear finder live in a new module,src/kiro_crew/security/stream_aws_anchor.py, built fromredaction._AWS_LABEL_RULESso the key lists cannot drift.redact()[\s"',}]or closing quote, or where the last nested carrier (?token=) ends.../Authorization:,...SecretAccessKey =)?token=drops end as on mainaws_session_token=...AccessKeyId, a bare 40-character run)begin) near the keyThe anchor is found by a linear scan with a few anchored matches, so a long run of repeated labels cannot stall the event loop. A stream that names no AWS key skips it after a substring check.
docs/system-specs/modules/security.mdnames the anchor, the cut rule and its cost. The security package line budget intest/test_security_gate_liveness.pyrises by the 356 lines this adds (217 of them the new module), from main's 31,509 to 31,865.Backwards compatibility
Compatible: the stream only holds more text back around an AWS label and drops a value that the batch pass would have redacted anyway; ordinary text and every other anchor stream as before (3,000 seeded no-AWS streams at random chunk sizes are byte-identical to main). The one benign-text cost is the fail-closed drop of a whitespace-free run over 4,096 characters that ends in an AWS pair.
Removes nothing: no key, API, record or text that main emits is taken away beyond that documented drop.
Tests
test/test_stream_redactor_aws_keyed.py:test_aws_keyed_value_past_the_floor_never_streams_rawtest_aws_keyed_value_under_the_ceiling_streams_as_the_batch_pass_writes_itredact()test_oversized_aws_keyed_continuation_is_discarded,test_aws_keyed_discard_stops_at_the_value_terminator,test_a_closed_value_past_the_ceiling_keeps_its_suffixtest_a_bare_secret_ending_in_a_key_name_before_a_long_value_never_streamsAccessKeyId,=and a 4,602-char value, chunks 1/7/64/600: no prefix of the run streamstest_a_long_whitespace_free_run_before_an_aws_pair_fails_closedtest_minified_json_past_the_ceiling_fails_closed_from_the_held_runtest_a_pem_word_before_an_aws_label_does_not_widen_the_dropbegin aws_secret_access_key=, open or closed by its quote, streams unchangedtest_a_finished_aws_pair_held_by_a_pem_word_is_not_split_by_the_floortest_a_label_glued_to_a_dropped_value_keeps_its_own_value_hidden,test_a_label_at_the_end_of_a_buffer_that_fails_closed_keeps_its_value_hiddentest_a_label_name_inside_a_dropped_value_does_not_end_the_drop?token=or AWS value, with no separator, never ends the droptest_a_value_glued_to_an_authorization_separator_stays_in_the_drop/Authorization:SECRETglued inside a dropped?token=or AWS value stays droppedtest_a_bare_run_glued_before_a_batch_match_is_not_splitAuthorization: Bearer ...&AccessKeyId=stays wholetest_a_label_after_a_long_run_is_held_once_its_separator_arriveskey =after a 1,500-char run holds the value that follows?token=, linear-finder and shape testsRed on
57b13481f3,65a6afee87orceb4d5f9ae(earlier heads), green here: the bare-secret, glued-run, glued-label, label-name-inside, glued-Authorization, PEM-word, PEM-held-pair and long-run tests. Three tests of the previous head are flipped or removed by the cut-rule ruling: the padded-label test is removed (that state machine is gone; the case is now a Not-a-goal), and the minified-JSON and short-pair tests now assert the fail-closed drop. A seeded differential fuzz of 4,000 mixed AWS / Bearer /?token=/ bare-run / glued-run / glued-label / PEM-word / padded-label streams at random chunk sizes: main leaks a secret piece the batch pass hides in 2,453, this branch in 295, and 28 cases leaked here but not on main before the glued-run and glued-label fixes (0 of those remain). One case still leaks here and not on main at that one chunking: a key name inside an earlier AWS value (a batch quirk), which leaks on main in 169 of 300 chunkings and here in 28. The other 294 are main-shared classes: padded labels, a key name inside an earlier AWS value, Bearer, bare runs. Feeding a 4 KB AWS value one byte at a time takes 1.20 CPU s, against 1.08 s for a 4 KB Bearer value.Determinism: seeded inputs, no clock. The file passed 218/218 in a parallel run.
Manual verification
N/A — unit coverage sufficient: the change is a pure function of the streamed text, and the tests drive it at every chunk size that matters.
Related Issues
Closes #17115
Pattern harvest
Rule candidate: review-prompt
Pattern: a batch redaction rule whose match spans a key and its value needs a matching stream anchor, or the stream floor splits them.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.