Repository navigation
fix(security): keep the key when redacting an AWS key-value credential - #28522
dodgeblaster wants to merge 1 commit into
Conversation
Sensitive change review
|
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
7bfccc0 to
0084b98
Compare
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: The change narrows what the redactor replaces in output. It does not add a stricter rule to the shell deny composite, so no confirmed regression came back. The one new refusal-shaped effect sits outside the shell classifier and is named under UNADJUDICATED: TIGHTENING: AWS key-value redaction span in pass 1 and in the stream fail-closed drop -- no new threat is refused. The change keeps the label and redacts only the value: ADJUDICATED: 16 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix and windows rows, no UNADJUDICATED:
[SCOPE-REVIEWED] e6236b5 |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff changes no UI control. It only changes how much of an AWS credential pair the redactor keeps in text that renders as before, so no screenshot is required. [UX-REVIEWED] e6236b5 Description read[DESCRIPTION-READ] e2e846c3bab91dc3699e8d0881417861d55ace2c5a1a925833a2c9918744dd6a That sha256 names everything this verdict read: the PR description, plus the 3 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Keeping the label is the decision record's own rule, and no credential pattern changes. The one take-away is the record Notes
[DESIGN-REVIEWED] e6236b5 Description read[DESCRIPTION-READ] 8d73a28f1cbe3bbdf003106f6cad07e6d6f1a9494b210d4c47c2538cbe78545a 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. The fix has a pinned defect and a recorded decision behind it. One note: the new tag-skip helper is broader than the existing pass-4 check. Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: when a JSON or config document holding an AWS credential is redacted, it keeps its key names and still parses. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] e6236b5 Description read[DESCRIPTION-READ] 83bab65363f41c4d34fe2b89daccd395c8d3d18e7d1326cf10a62b54968c68c1 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: |
0084b98 to
17892af
Compare
|
|
The three AWS key-value branches of _CREDENTIAL_PATTERNS (aws_secret_access_key / SecretAccessKey, aws_session_token / SessionToken, aws_access_key_id / AccessKeyId) matched the key name, separator, quote and value together, and pass 1 replaced the whole match, so {"aws_secret_access_key": "SECRET", "region": "x"} became {"[REDACTED: credential]", "region": "x"}: not JSON, and the Files view showed Invalid JSON.
Pass 1 now starts the redacted span after the _AWS_LABEL_RULES label, with no pattern change, and writes an empty record label because the label stays in the text. A value made only of a fixed credential tag's bytes is left alone so the output is a fixed point of the redactor. The stream ceiling discard keeps the same label for a sole AWS carrier, so an over-ceiling value fails closed to the batch output.
The browser mirror in website/src/utils/sanitize.ts keeps the label the same way and leaves a value that is already a redaction tag alone, so it no longer garbles the backend's kept-label output.
Fixes #22576
17892af to
e6236b5
Compare
|
|
[operator: bolichen97] Continuing this in #32401; thanks for the start. |
The three AWS key-value branches of the credential alternation match
the key name, separator, optional quote and value together, and pass 1
replaced the whole match. A JSON document holding
{"aws_secret_access_key": "<secret>", "region": "x"} collapsed to
{"[REDACTED: credential]", "region": "x"}, so it no longer parsed and
the reader lost which field was redacted.
Pass 1 now keeps the _AWS_LABEL_RULES label and redacts only the value
after it; the record names no label because the text shows it. A value
made only of a credential tag's bytes (whole, cut by the end of the
text, with its space dropped, or in a JSON-escaped quote) is left
alone, so redacting the output again, a delivered piece of it, or the
string it was serialized into changes nothing. The dashboard mirror in
sanitize.ts leaves a value that is already a backend tag as written.
Builds on #28522 by @dodgeblaster.
Closes #22576
Co-authored-by: Gary Jennings <garysjennings@gmail.com>
The three AWS key-value branches of the credential alternation match
the key name, separator, optional quote and value together, and pass 1
replaced the whole match. A JSON document holding
{"aws_secret_access_key": "<secret>", "region": "x"} collapsed to
{"[REDACTED: credential]", "region": "x"}, so it no longer parsed and
the reader lost which field was redacted.
Pass 1 now keeps the _AWS_LABEL_RULES label and redacts only the value
after it; the record names no label because the text shows it. A value
made only of a credential tag's bytes (whole, cut by the end of the
text, with its space dropped, or in a JSON-escaped quote) is left
alone, so redacting the output again, a delivered piece of it, or the
string it was serialized into changes nothing. The dashboard mirror in
sanitize.ts leaves a value that is already a backend tag as written.
Builds on #28522 by @dodgeblaster.
Closes #22576
Co-authored-by: Gary Jennings <garysjennings@gmail.com>
The three AWS key-value branches of the credential alternation match
the key name, separator, optional quote and value together, and pass 1
replaced the whole match. A JSON document holding
{"aws_secret_access_key": "<secret>", "region": "x"} collapsed to
{"[REDACTED: credential]", "region": "x"}, so it no longer parsed and
the reader lost which field was redacted.
Pass 1 now keeps the _AWS_LABEL_RULES label and redacts only the value
after it; the record names no label because the text shows it. A value
made only of a credential tag's bytes (whole, cut by the end of the
text, with its space dropped, or in a JSON-escaped quote) is left
alone, so redacting the output again, a delivered piece of it, or the
string it was serialized into changes nothing. The dashboard mirror in
sanitize.ts leaves a value that is already a backend tag as written.
Builds on #28522 by @dodgeblaster.
Closes #22576
Co-authored-by: Gary Jennings <garysjennings@gmail.com>
|
Closing this as superseded by #32401, which targets #32401 doesn't cover one piece of this PR: the stream redactor keeping the AWS key when a value outgrows the holdback ceiling, including the closing quote. I've offered that piece on #32401, with the cases that differ between the two branches: #32401 (comment) The branch stays in place so the commit links in that comment keep working. |
The backend redactor now keeps an AWS key's label and masks only its
value, so {"aws_secret_access_key": "<secret>", "region": "x"} keeps
its key and still parses. The dashboard sanitizer read that output as
a raw key assignment: sanitizeLlmOutput turned
aws_secret_access_key=[REDACTED: credential] into
[REDACTED] credential], dropping the key the backend kept and garbling
the tag on the approval prompt and the workflow run labels.
The sanitizer's key-assignment reader now leaves a value that is
already a backend tag, after an opening quote that may be JSON-escaped,
as written. A raw value is still redacted. The security spec's frontend
sanitizer bullet says the same.
Builds on #28522 by @dodgeblaster.
Closes #22576
Co-authored-by: Gary Jennings <garysjennings@gmail.com>
The backend redactor now keeps an AWS key's label and masks only its
value, so {"aws_secret_access_key": "<secret>", "region": "x"} keeps
its key and still parses. The dashboard sanitizer read that output as
a raw key assignment: sanitizeLlmOutput turned
aws_secret_access_key=[REDACTED: credential] into
[REDACTED] credential], dropping the key the backend kept and garbling
the tag on the approval prompt and the workflow run labels.
The sanitizer's key-assignment reader now leaves a value that is
already a backend tag, after an opening quote that may be JSON-escaped,
as written. A raw value is still redacted. The security spec's frontend
sanitizer bullet says the same.
Builds on #28522 by @dodgeblaster.
Closes #22576
Co-authored-by: Gary Jennings <garysjennings@gmail.com>
Problem / Motivation
Goal: Redacting an AWS key-value credential keeps the key name and replaces only the value, so a JSON or config document that holds one still parses after redaction.
The three AWS key-value branches of
_CREDENTIAL_PATTERNS(aws_secret_access_key/SecretAccessKey,aws_session_token/SessionToken,aws_access_key_id/AccessKeyId) match the key name, separator, optional quote and value together, and pass 1 replaces the whole match. So{"aws_secret_access_key": "SECRET", "region": "x"}comes out as{"[REDACTED: credential]", "region": "x"}, which is not JSON: the Files view showsInvalid JSON, and logs, Slack and copied text lose the field name. This is the same defect #21488 fixes forAuthorization: Bearer.Why it matters
STS
AssumeRoleoutput,~/.awsdumps, boto debug logs and any config that carries an AWS credential become unreadable wherever redaction runs (Files view, chat, transcripts, channels, logs). The secret was always removed; the document's structure was destroyed with it. The maintainer decision recorddocs/decisions/2026-10-20-redaction-classifies-by-what-a-value-can-do.mdalready states the rule: the value is replaced and the label is kept.Not a goal
AccessKeyIdvalues stay redacted. Tiering key IDs as identifiers is Redaction: classify by what a value can do (Secret / Bearer link / Identifier) #22552's phase, not this PR's.src/kiro_crew/security/redaction_rules/) is not touched; it already keeps labels.What changed (motivation → approach → change)
Symptom: a valid JSON document holding an AWS credential pair redacts to non-JSON. Root cause: pass 1 of
_credential_redaction_planreplaces each match whole, and the AWS branches' match starts at the key. Change: pass 1 already split the label from the value (_AWS_LABEL_RULES, used only for the record); it now starts the redacted span after that label, so no pattern changes. Because the label is now in the text, the record'slabelis"", and the chat lock tag, which drawsrecord.labelbefore itself, does not show the key twice.Keeping the label exposes the redactor's own output to itself: the value class accepts
[, soaws_secret_access_key=[REDACTED: credential]would re-redact into[REDACTED: credential] credential]. A value made only of a fixed credential tag's bytes is therefore left alone (a whole tag ended by the text or a value terminator, a tag cut by the end of the text, or a tag with its space dropped), which keeps the output a fixed point and keeps delivery cuts through a tag clean. A value that only starts like a tag ([REDACTED<secret>) is still redacted.The stream redactor's fail-closed ceiling discard keeps the same label when the AWS pair is the only carrier and the drop starts at its own key (past only JSON member punctuation or whitespace), so an over-ceiling value fails closed to the batch output, with a closed value's closing quote kept; a drop that starts earlier in a whitespace-free run keeps the whole drop, since a cut inside that run could bisect a secret.
The browser-side mirror
website/src/utils/sanitize.ts(workflow graph labels and titles) replaced the whole AWS pair with[REDACTED], so it read the backend's newaws_secret_access_key=[REDACTED: credential]as a pair and showed[REDACTED] credential]. A defect this PR causes, so it is fixed here: the mirror keeps the label too, replaces only the value, and leaves a value alone only when it is exactly a redaction tag ended by whitespace, a quote,,,}or the end of the text; a tag with text glued after it is redacted whole. Its base64 decode-and-scan checks decoded text against the AWS key-value patterns as well.Backwards compatibility
Compatible: every value that was redacted is still fully replaced at the same match position; only the kept span changes, from the whole pair to the value alone.
The record's
labelfor these three rules becomes"", because the label is now in the text. Records already stored keep their old label beside their old collapsed text, so they stay consistent.Reader: website/src/components/RedactionCards.tsx:CredentialTag -- chat -- renders
record.label(now empty) before the lock tag, and the key name is already in the text before itReader: website/src/components/RedactionCards.tsx:copyTextForRedactedCode -- chat -- copies
label + <REDACTED>, which now follows the in-text label, so a copy reads"aws_secret_access_key": "<REDACTED>"Reader: src/kiro_crew/security/credential_sources.py:credential_record -- chat -- passes the label through when it matches
_LABEL_RE; an empty label is already accepted (test_a_file_read_names_path_section_and_the_aws_template)Tests
Proof: PROVEN test/test_aws_key_value_redaction.py::test_a_config_line_keeps_its_label[equals-aws_secret_access_key], test/test_aws_key_value_redaction.py::test_a_config_line_keeps_its_label[equals-SecretAccessKey], test/test_aws_key_value_redaction.py::test_a_config_line_keeps_its_label[equals-aws_session_token], test/test_aws_key_value_redaction.py::test_a_config_line_keeps_its_label[equals-SessionToken], test/test_aws_key_value_redaction.py::test_a_config_line_keeps_its_label[equals-aws_access_key_id] (head e6236b5)
test/test_aws_key_value_redaction.py(new): all 6 spellings × spaced/compact JSON parse with the value gone; config-line forms keep the label; anAKIAvalue afterAccessKeyIdis still redacted; the redactor is a fixed point on its own output; the record names the rule with an empty label; values made of a tag's bytes are left alone while tag lookalikes are redacted; a label glued to a bare-secret run hides both secrets; an over-ceiling streamed value keeps its label like the batch pass at chunk sizes 1/7/64/whole. With the production change reverted 86 of its 104 cases fail; with only the stream change reverted, 30 fail.test/test_credential_prefilter.py: the by-span reference oracle mirrors the AWS label span and the tag guard with its own spelled-out label regex, so the byte-identical differential (fuzz included) still holds; AWS-bearing corpus texts join the bearer ones intest_key_preserving_branches_keep_the_prefix_the_legacy_oracle_dropped;test_partly_claimed_run_keeps_no_plaintexttakes its partly-claimed run from a glued GitLab token, since an AWS label no longer gives pass 1 the run's tail.test/test_stream_redactor_aws_keyed.py,test/test_credential_sources.py,test/test_cron_script_sessions.py,test/test_redaction_credential_records.py,test/test_security_regex_linearity.py,test/test_slack_render_pipeline.py,test/test_dashboard_chat_pagination_suffix.py: updated to the kept label and empty record label (the cron example now breaks the serialized blob with a value followed by an escaped quote; the pagination fixture collides two labelled assignments instead of a key id and an assignment).website/src/test/sanitizeCredentials.test.ts: each of the 6 spellings keeps its label with only the value replaced, a value already redacted ([REDACTED: credential],[REDACTED: encoded credential],[REDACTED]) is unchanged, and a value that only starts like a tag, or a secret glued after a whole tag, is still redacted, and a base64-encoded key-value pair is redacted; 14 of its 23 cases fail with thesanitize.tschange reverted.test/test_security_gate_liveness.py: package line budget 33,759 → 33,800, reason recorded above the pin.Manual verification
N/A — unit coverage is sufficient: the tests assert
json.loadson the redacted output that the Files view parses, and stream/batch parity at several chunk sizes.Screenshots / video
Why no screenshot: the only frontend change is the text a credential-bearing workflow label redacts to (
key=[REDACTED]instead of[REDACTED]), with no layout, style or component change, andwebsite/src/test/sanitizeCredentials.test.tspins it.Related Issues
Fixes #22576
Part of #22552 (value-only replacement for the AWS key-value branches)
Sibling sweep
Swept: git grep -nE "SecretAccessKey|aws_secret_access_key" -- src/kiro_crew/security/ website/src/utils/
Sibling: src/kiro_crew/security/text_redaction.py -- changed here
Sibling: src/kiro_crew/security/redaction_rules/redact.py -- not affected -- the rule table already replaces the value and keeps the label
Sibling: website/src/utils/sanitize.ts -- changed here
Pattern harvest
Rule candidate: review-prompt
Pattern: a key-anchored credential regex replaced whole takes the key, separator and quote with the value; redact only the value span, and keep the redactor a fixed point on its own tag.
Checklist