Skip to content

fix(security): keep the key when redacting an AWS key-value credential - #28522

Closed
dodgeblaster wants to merge 1 commit into
fix/13873-redaction-keeps-json-keyfrom
fix/22576-aws-kv-redaction-key
Closed

dodgeblaster wants to merge 1 commit into
fix/13873-redaction-keeps-json-keyfrom
fix/22576-aws-kv-redaction-key

Conversation

@dodgeblaster

@dodgeblaster dodgeblaster commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #21488. This branch is cut from #21488's head (fix/13873-redaction-keeps-json-key) and targets that branch, so the diff here is only the AWS change. It retargets to main once #21488 merges.

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 shows Invalid JSON, and logs, Slack and copied text lose the field name. This is the same defect #21488 fixes for Authorization: Bearer.

Why it matters

STS AssumeRole output, ~/.aws dumps, 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 record docs/decisions/2026-10-20-redaction-classifies-by-what-a-value-can-do.md already states the rule: the value is replaced and the label is kept.

Not a goal

  • No change to which inputs are redacted: no credential pattern, branch or pass is added, removed or widened, and the regex text is unchanged, so the pre-filter and native gate are untouched.
  • AccessKeyId values 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.
  • The not-yet-wired rule table (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_plan replaces 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's label is "", and the chat lock tag, which draws record.label before itself, does not show the key twice.

Keeping the label exposes the redactor's own output to itself: the value class accepts [, so aws_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 new aws_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 label for 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 it
Reader: 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; an AKIA value after AccessKeyId is 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 in test_key_preserving_branches_keep_the_prefix_the_legacy_oracle_dropped; test_partly_claimed_run_keeps_no_plaintext takes 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 the sanitize.ts change 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.loads on 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, and website/src/test/sanitizeCredentials.test.ts pins 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

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 7bfccc0
  • What rule changed: Pass 1 of _credential_redaction_plan (src/kiro_crew/security/redaction.py) now starts the redacted span of the three AWS key-value branches (aws_secret_access_key / SecretAccessKey, aws_session_token / SessionToken, aws_access_key_id / AccessKeyId) after their _AWS_LABEL_RULES label (key name, separator, optional opening quote), and writes label="" on those records. A value made only of a fixed credential tag's bytes (a whole CREDENTIAL_REDACTION_TAGS member ended by the text or a value terminator, a member cut by the end of the text, or a member with its space dropped) is left alone, so the output is a fixed point. The stream redactor (src/kiro_crew/security/text_redaction.py) keeps the same label in its fail-closed ceiling discard when the AWS pair is the sole carrier and the drop starts at its own key (past only {[,"' or whitespace). No credential pattern was added, removed or widened; the regex text, the pre-filter and the native gate are unchanged.
  • Before -> after (what was allowed/blocked, now): Before, {"aws_secret_access_key": "SECRET", "region": "x"} redacted to {"[REDACTED: credential]", "region": "x"} (not JSON). After, it redacts to {"aws_secret_access_key": "[REDACTED: credential]", "region": "x"}. The same inputs match at the same positions; only the replaced span narrows to the value. Blocking (_contains_fixed_credential, exfil.py) is untouched.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): (1) The tag guard skips a value that holds secret bytes. Guarded: the guard accepts only bytes of a public tag constant (byte-identity with a member, a prefix of a member reaching the end of the text, or the space-dropped member), so [REDACTED<secret>, [REDACTED:<secret> and [REDACTED:credential]<secret> are still redacted (test_a_value_that_only_starts_like_a_tag_is_redacted). (2) The stream keeps a label whose commit bisects a secret. Guarded: the label is kept only when the bytes between the safety cut and the key are JSON punctuation or whitespace; a drop that starts earlier in a whitespace-free run keeps the whole drop (test_a_long_whitespace_free_run_before_an_aws_pair_fails_closed, test_a_bare_secret_ending_in_a_key_name_before_a_long_value_never_streams pass unchanged).
  • Evidence checked (which sandbox result proves it): test/test_aws_key_value_redaction.py (104 cases: JSON parses with the value gone for all 6 spellings × spaced/compact, fixed point, empty record label, tag guard both ways, stream/batch parity past the ceiling at chunk sizes 1/7/64/whole); 86 of them fail with the production change reverted and 30 with only the stream change reverted. test/test_credential_prefilter.py byte-identical differential (incl. fuzz) against an oracle with its own spelled-out label regex and tag check. The split-delivery seam suites (test_split_credential_boundary_readings.py, ..._sealed_seams.py) pass, which is what required the cut-tag and space-dropped-tag shapes.
  • No regression:
    • Tools still work (which tools/commands were run, result): Ran 123 redaction/security/display/split/stream/transcript-related test files from the change-scoped set (10,041 passed) and the 43 further related files that name an AWS key (3,839 passed); the one remaining failure (test_auto_improvement_members.py::test_assignments_build_real_context_from_only_their_private_store) fails identically with this change reverted (local scratch-path environment).
    • Backward compatible (old config / old data / old callers still work, how checked): redact_credentials / redact_credentials_with_records signatures and return shapes are unchanged. Stored records keep their old label beside their old collapsed text; new records carry label="", which credential_sources.credential_record and RedactionCards.tsx already accept.
    • Existing tests (which suites passed on this head): The suites above; black (repo gate), isort, flake8, mypy clean on touched files; comment-history gate passes; package line budget 33,759 -> 33,795 with the reason recorded.
  • How to undo: Revert the single commit 7bfccc021688175efa96e5d088d68a3c3096a3ef (git revert); the AWS branches return to whole-match redaction. No data migration or config change.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/redaction.py

  • src/kiro_crew/security/text_redaction.py

  • @dodgeblaster comment: does not name the current head e6236b5; post it again for this head

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: e6236b55465f762a54d68e1490c50b251ec5bfb4
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/22576-aws-kv-redaction-key branch from 7bfccc0 to 0084b98 Compare November 2, 2026 20:42
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does e6236b55465f762a54d68e1490c50b251ec5bfb4 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • ubuntu-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • windows-latest (platform windows): 6 classified, 0 newly refused, 6 still allowed.

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: _value_is_redaction_tag now skips values made of tag bytes, which changes the result of redact_credentials(x) != x checks.

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: start = prefix_end if prefix_end != -1 else m.start() + len(label) and if label and _value_is_redaction_tag(text, start, m.end()): continue in redaction.py::_credential_redaction_plan, plus i = max(i, aws_keyed_anchor.start("val")) in text_redaction.py::StreamRedactor.feed. The only stricter piece is sanitize.ts. A value that starts with a backend tag now takes \[REDACTED: (?:encoded )?credential\]\S*, so a secret glued after a tag is consumed.

ADJUDICATED: 16 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix and windows rows, no any rows. The diff adds no path, separator, interpreter or env-var assumption to a shell guard. The rows probe the AWS CLI profile operations next to the touched labels (aws configure get/list/set, sts get-caller-identity, a CloudFormation read) in both spellings. They also cover the maintainers' own test and grep runs on the changed files with / and \ paths and cmd findstr, plus a jq read of an assumed-role session file with posix and cmd quoting. The scrub rule bans a labelled aws_secret_access_key/aws_session_token followed by =/: and a value, so no row could carry the exact label-plus-value boundary.

UNADJUDICATED:

  • Guard: security/exfil.py::_credential_clean (redact_credentials(value)[0] != value, and the same check on each percent-decoded form). Callers reach it through _blocked_link_url_verdict when deciding whether a blocked-link record keeps its full address. Other redact(text) != text admission predicates do the same: _gate_upload_file and a non-owner's outbox download. The new tag-value skip makes these check results looser, not stricter, so values like the following now read as clean:

    • a JSON or URL query member whose AWS secret-key label is followed by a whole [REDACTED: credential] tag;
    • the same label followed by the tag cut at the end of the text;
    • the same label followed by the tag with its space removed.

    Inputs I would have submitted: a link whose query carries an AWS secret-key label set to a whole tag; the same with a tag cut by the end of the text; the same with the space-stripped tag. These are not rows, because the classifier does not reach this path and the label shape is scrub-refused. These checks are a separate concern from this lane's. They are noted for the lanes that judge whether the change is secure enough.

  • Guard: website/src/utils/sanitize.ts KEYED_CRED_PATTERNS (VALUE = (?:\[REDACTED: (?:encoded )?credential\]\S*|\S+)). Dashboard text reaches it through sanitizeCredentials(text). Inputs nothing could classify:

    • a config line where a tag is followed by ordinary glued punctuation, such as a trailing ) or . after the tag in prose. The old \S+ stopped at the space inside the tag, while the new alternative takes the tag plus the glued )/. and rewrites it to [REDACTED]. Only the display changes; nothing is refused.
    • a label with a lowercase-first key spelling (secretAccessKey, matched under the gi flag) whose value is a backend tag followed by a newline. This should stay unchanged under TAG_VALUE.

    This is display-side, with no verdict available.

[SCOPE-REVIEWED] e6236b5

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of e6236b55465f762a54d68e1490c50b251ec5bfb4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of e6236b55465f762a54d68e1490c50b251ec5bfb4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 label becoming "", and its readers are listed and accept an empty label.

Notes

  • _value_is_redaction_tag adds a second fixed-point rule that every later key-preserving branch will also need. If a third branch keeps its prefix, move it to one shared "value already a placeholder" check rather than a copy per branch.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e6236b55465f762a54d68e1490c50b251ec5bfb4 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 3 — oversized: _value_is_redaction_tag (redaction.py:999) is a third spelling of "this value is already a tag". I grepped CREDENTIAL_REDACTION_TAGS and found the other two. Pass 4 at redaction.py:1342 skips only on byte-identity (text.startswith(tag, value_start)). Its comment says trust is "BYTE-IDENTITY with a module-owned fixed literal, never a shape". The stream at text_redaction.py:354 already holds back a cut tag prefix. The new "cut by end of text" and "space dropped" branches are shape-based acceptance that neither existing site needed, and no defect is named for them. Subtraction: reduce the AWS skip to the pass-4 whole-tag test followed by a value terminator, and drop the cut and joined branches and their test_a_value_made_of_a_tags_bytes_is_left_alone cases.

What this change ships

Inventory (7 items) — 6 justified

Intent: when a JSON or config document holding an AWS credential is redacted, it keeps its key names and still parses. This is a FIX.

  1. AWS key-value redaction keeps the key, separator and quote, and replaces only the value — justified
  2. The AWS credential record's label is now empty, so the chat lock tag no longer shows the key twice — justified
  3. A value that is already a redaction tag (whole, cut, or with its space dropped) is left alone — oversized: the cut and joined shapes go beyond the pass-4 byte-identity skip
  4. A streamed value over the 4096-character ceiling keeps its AWS label, matching the batch output — justified
  5. The browser sanitizer (sanitize.ts) keeps the AWS label and leaves backend tags alone — justified
  6. The browser's base64 decode-and-scan still checks the moved AWS patterns — justified
  7. The package line budget is raised from 33,759 to 33,800, with the reason recorded — justified

[FIRST-PRINCIPLES-REVIEWED] e6236b5

Description read

[DESCRIPTION-READ] 83bab65363f41c4d34fe2b89daccd395c8d3d18e7d1326cf10a62b54968c68c1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed e6236b55465f762a54d68e1490c50b251ec5bfb4 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e6236b5

Verdict parsed from the review's SHA-scoped output markers for commit e6236b55465f762a54d68e1490c50b251ec5bfb4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e6236b55465f762a54d68e1490c50b251ec5bfb4 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of e6236b55465f762a54d68e1490c50b251ec5bfb4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e6236b5

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e6236b55465f762a54d68e1490c50b251ec5bfb4 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 2, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/22576-aws-kv-redaction-key branch from 0084b98 to 17892af Compare November 2, 2026 21:32
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • AWS key-value mirror in website/src/utils/sanitize.ts: base64 detection and tag-prefix exemption

fixed in 17892af: both findings on this span. (1) decodeB64Safe tests decoded text against KEYED_CRED_PATTERNS too, so base64 of secretAccessKey=<secret> is redacted. (2) The tag exemption applies only when the value is exactly a tag followed by whitespace, a quote, ,, } or end of text; a value starting with a spaced backend tag takes the tag and everything glued after it, so secretAccessKey=[REDACTED]<secret> and secretAccessKey=[REDACTED: credential]<secret> are both redacted.
Pinned by website/src/test/sanitizeCredentials.test.ts ("redacts a secret glued after a whole tag", "redacts a base64-encoded key-value pair"), which fail with the fix reverted.

@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • Extracting AWS patterns disables their base64 detection (website/src/utils/sanitize.ts:99)

fixed in 17892af: decodeB64Safe tests decoded text against KEYED_CRED_PATTERNS as well as CRED_PATTERNS, so a base64-encoded AWS key-value pair is replaced with [REDACTED: encoded credential] again.
Pinned by website/src/test/sanitizeCredentials.test.ts "redacts a base64-encoded key-value pair", which fails with the fix reverted.

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
@dodgeblaster
dodgeblaster force-pushed the fix/22576-aws-kv-redaction-key branch from 17892af to e6236b5 Compare November 2, 2026 23:36
@dodgeblaster

Copy link
Copy Markdown
Contributor Author
  • Preserve the closing quote alongside the AWS label (text_redaction.py:568)

fixed in e6236b5: when the label is kept and the AWS value's closing quote has arrived, the quote stays buffered (drop_end stops before it), so a streamed over-ceiling value ends as label, opening quote, tag and closing quote, byte-identical to the batch output.
Pinned by test_a_closed_value_past_the_stream_ceiling_keeps_its_closing_quote (3 keys x 5 chunk sizes, closing quote ending one chunk and } arriving in the next); 3 cases fail with the fix reverted.

@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #32401; thanks for the start.

bolichen97 added a commit that referenced this pull request Nov 7, 2026
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>
bolichen97 added a commit that referenced this pull request Nov 8, 2026
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>
bolichen97 added a commit that referenced this pull request Nov 8, 2026
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>
@dodgeblaster

Copy link
Copy Markdown
Contributor Author

Closing this as superseded by #32401, which targets main and builds on this PR. This PR's base, #21488, is closed, and its Bearer half landed on main as #32367.

#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.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 9, 2026
bolichen97 added a commit that referenced this pull request Nov 17, 2026
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>
KiroCrewCaptain pushed a commit that referenced this pull request Nov 17, 2026
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>
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.

2 participants