Skip to content

fix(security): redact a streamed link cut inside its query as one link - #20805

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/stream-redact-url-tail-20769
Oct 18, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/stream-redact-url-tail-20769

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A blocked link that streams in over more than one chunk is saved, copied and posted as one placeholder, with none of its query left behind.

Chat text is redacted one streamed piece at a time. When a piece ends inside a blocked link's query, the first part becomes [REDACTED: suspicious URL to <host>] and the rest of the query (&X-Amz-Date=...&X-Amz-Security-Token=...&X-Amz-Signature=...) is saved as plain text right after it. When the cut falls before the access key, the key becomes a credential tag and the rest of the link (session token and signature) stays plain around it. The saved reply feeds the copy button, channel posts and the message log, so the signature and token reach all of them. The live stream had a wider gap: a link longer than 512 characters went out in 512-character pieces, none of which the link check could judge, so the whole presigned link minus its key reached every open tab.

Why it matters

A presigned S3 link is a working credential until it expires. Anyone who reads the saved reply, a copied message or a channel post can use the session token and signature. Streaming makes the cut the common case, not a rare one.

Not a goal

  • The dashboard-only display fold for the query tail (PR fix(chat): fold a presigned tail into its chip; list a lone record #20765, blockedLinkQueryTail). This PR does not depend on it; rows saved before this change still carry a tail, so it stays useful for them.
  • Rewriting rows already saved with a tail. Nothing on disk is rewritten.
  • Any change to which links are blocked. No pattern, threshold or exemption moves, and StreamRedactor is unchanged.

What changed (motivation → approach → change)

Symptom: a link cut by a delta boundary is saved in pieces. Fix: at save time, redact the whole reply once, from the slot's raw copy.

  • _redact_segment (in chat_turn/segment_flush.py) runs the slot's raw copy of the deltas, with the streamed glued-footer reflow, through both removers once. A cut link is judged as one link, and the records come from that same pass. The earlier regex folds are gone.
  • security/ gains two optional arguments and moves no matcher: redact_exfiltration_urls_with_records(removed_out=) hands back each replaced address, and redact_credentials_with_records takes defer_token_param.
  • exfil.py now rewrites blocked links longest first. In match order, a blocked link that prefixes a longer one (plus &X-Amz-Security-Token=...) rewrote the longer one's head and left its token tail (GPT 6.1 on 5ae2569fad). Blocked links, warnings and records are unchanged. Fixes Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 for every caller.
  • Default refuse: main's own save (the streamed text redacted again) is the only proof that text is safe to keep. Every whitespace-delimited run the saved text shows (each placeholder set off as its own run, blocked-link domains included) must appear in it (_saved_text_shows_more); nothing else vouches, so no glued, quoted, PEM-wrapped or forged shape can launder a value a delta hid. This replaces nine rounds of per-shape checks and closes that loop by design. A blocked-link record is kept only for a placeholder the saved text holds and when it quotes only main's text or an address a delta blocked whole (_links_main_shows); otherwise the record is dropped and the placeholder stays. The raw copy is never edited (maintainer ruling).
  • Causes left open: the whole-text matcher misses a link token right after . (Credential redactor keeps a link token that follows a '.' #21550), and a greedy match over two glued credentials leaves the second one's body (Credential redaction keeps most of a second token glued to the first #21595). Once both are fixed, _saved_text_shows_more, segment_removed, removed_out=, _kept_removed_values, _records_hold_removed_credential and _SEGMENT_CHECK_MAX_WORK can be deleted.
  • Fail closed: the row is _SEGMENT_UNCHECKED_TEXT with no records, never raw text, when there is no raw copy (past _SEGMENT_RAW_MAX_CHARS), the raw copy does not hash to the streamed text, a pass raises, the result holds a removed value or shows text main's save hid, a record (_records_hold_removed_credential: blocked-link url/path/domain, credential view_command/profile_command/source fields) holds a removed value, or the checks would pass _SEGMENT_CHECK_MAX_WORK.
  • Accepted cost (maintainer ruling): withheld replies. Measured chunk sizes: 6 real kiro-cli turns, 480 chunks, max 42 chars, 0 of 100+ chars; recorded opencode/pi/deepseek/codex fixtures, 46 chunks, about 30% of 100+. Withheld at those sizes (300 replies each): kiro 0% for presigned, sink and plain links; large-chunk backends 7% presigned, 0% sink and plain; base64 blob 7 of 200.
  • With no streamed deltas the text itself is redacted. _reflow_label_and_audit runs inside _redact_segment. _ChatSlot gains segment_shown_sha and segment_removed (memory only); _CREDENTIAL_TAG_RE is removed. Package line budget 29,574 -> 29,590.

Open until #20817 (blocking follow-up): the five live StreamRedactor sites (chat_runner.py _wsred/_thinkred, chat_threads.py, handlers/side.py, messaging/driver.py, slack/handler_runtime/stream.py), the subagent SSE tail and native card output still redact each chunk alone.

Only the comments of MarkdownRenderer.blockedLinkCredInUrl.test.tsx and MarkdownRenderer.blockedLinkOneOne.test.tsx change: their fixtures are now legacy per-delta rows.

Backwards compatibility

Compatible: nothing that works today stops working. A saved reply holds the whole-text redaction of what the model wrote. A segment over 2,000,000 characters, or one that cannot be checked, is saved as a one-line withheld notice instead of its streamed text (logged with the reason).

Reader: src/kiro_crew/dashboard/chat_runner.py:_flush_segment -- chat -- saves _redact_segment output; test_presigned_link_cut_by_a_delta_saves_as_one_placeholder
Reader: src/kiro_crew/dashboard/chat_runner.py:_persist_partial_reply -- chat -- same; test_an_interrupted_reply_collects_records_at_its_own_redaction
Reader: src/kiro_crew/dashboard/chat_utils.py:_prepare_messages -- chat -- display re-redaction unchanged; test_chat_utils.py passes
Reader: src/kiro_crew/dashboard/chat_runner.py:crew_log_emit.on_message_sent -- chat -- logs the same redacted body
Reader: website/src/components/MarkdownRenderer.tsx -- crew page -- renders placeholders as chips; fixtures unchanged

Tests

All in test_chat_runner_coverage.py::TestBlockedLinkCardRecords unless named; test_a_disagreeing_raw_copy_is_not_trusted and test_records_come_from_the_one_whole_text_pass are in test_chat_runner_coverage_output.py::TestFlushSegment.

  • Original repro: test_presigned_link_cut_by_a_delta_saves_as_one_placeholder (seven cuts, six red on main) and test_presigned_links_cut_anywhere_save_no_query (three layouts, every 7th cut plus 2-5 cut sets).
  • Every bypass shape review found on the fold heads, kept as regression cases: echoed same-host placeholders (one and two), a credential tag spanning &, nested links (cut before and behind a 210-char outer query), a label that eats the address head or a placeholder head (also nested), an unrelated placeholder glued before the link (and 1,100 of them), a tag inside an unblocked outer link, a long query before a key cut, credential ordinals after a fold, and the round-24 shapes: test_a_segment_too_large_for_a_raw_copy_fails_closed (cut before and after the key, no raw copy) and test_a_hostname_shaped_like_a_key_does_not_shelter_a_cut_query (every 5th cut).
  • New: test_a_saved_segment_is_the_raw_copy_redacted_once (prose glued to a quoted placeholder and a kept same-host link survive; the old accepted cost is gone), test_key_split_links_are_withheld_not_saved_unredacted (default refuse: a cut same-host presigned link the whole text keeps is withheld), test_the_streamed_footer_reflow_is_applied_to_the_saved_copy, test_a_value_only_a_per_delta_pass_removed_withholds_the_segment, test_each_removed_value_is_checked_on_its_own (GPT's round-1 shape: a .-led link token and a PAT in one delta; now withheld), test_benign_replies_cut_anywhere_are_saved[False|True] (200 random cut sets over code and a link never withhold; with a base64 blob each flush is the saved reply or the notice), test_a_kept_removed_value_fails_closed, test_a_check_past_the_work_ceiling_fails_closed_without_scanning, test_a_token_repeated_inside_a_blocked_link_is_never_saved (GPT 6.1's shape on 215f080: the mask's space cut a blocked link before its query; red on that head), test_a_record_holding_a_value_only_a_per_delta_pass_removed_fails_closed (GPT 6.1's shape on 326fee0: the token reached meta.blocked_links[].url; red without the record check), test_a_record_check_ignores_blocked_addresses_and_finds_nested_values, test_a_redaction_pass_that_raises_fails_closed, test_a_disagreeing_raw_copy_is_not_trusted, test_records_come_from_the_one_whole_text_pass, test_a_normally_streamed_turn_never_saves_the_withheld_notice (a real _run_chat turn with a cut blocked link saves the reply, not the notice; red when the streamed text gets a writer the raw copy does not see), test_a_blocked_link_extended_into_a_token_form_in_a_later_delta_is_saved_redacted (a real turn: a blocked link, then the same link with a token appended in the next delta; red before the longest-first rewrite), test_a_credential_record_quoting_a_removed_value_fails_closed, test_a_credential_a_glued_neighbour_cut_into_withholds_the_segment, test_text_a_delta_hid_and_a_glued_match_exposes_withholds_the_segment[...] (every glued, quoted, PEM-wrapped and forged-opener shape the local GPT and Opus reviewers found; each red on the head before its fix), test_only_mains_own_text_vouches_for_a_saved_run, test_a_presigned_link_cut_anywhere_in_two_deltas_saves_no_key, test_key_split_links_are_withheld_not_saved_unredacted (default refuse: the cost, pinned), test_a_record_whose_placeholder_a_later_match_swallowed_is_dropped (GPT 6.1's CI shape on 75f564b6c2), the a-connection-string-a-glued-token-swallowed case (Opus), and in test_redaction_blocked_links.py test_a_blocked_link_that_prefixes_a_longer_one_cannot_shelter_its_tail[False|True] (the Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 repro in one call; the shorter-first case is red on main).

Run on Linux, on this head (one commit on main 52a302b914): black, isort, flake8, mypy (2,828 files), the flake ratchet, the repo's semgrep rules and semgrep p/secrets clean (0 findings); the chat runner, segment, redaction, liveness and composition suites 659 passed. Local review: GPT 6.1 and Opus 5.5 pinned reviewers (agent kirocrew-research) PASS on this head. Opus fuzzed text and records at delta sizes 2-500 with 0 new values saved, and CI GPT 6.1's last shape on 76207bf00a (a bracketed password rebuilt from pieces the reply repeats) is closed by splitting runs on whitespace only, with each placeholder set off as its own run. scripts/local-gate.py results are in the Sensitive Change note. Package line budget 29,574 -> 29,590 with the reason. No repo hooks are installed in this clone, so none ran.

Manual verification

N/A: unit coverage drives the exact streaming path (per-delta removers, raw copy, segment flush) and the stream redactor; no UI change.

Screenshots / video

No component changes. The new saved state is the withheld notice, shown as it renders in a reloaded thread: the first assistant segment was withheld, the second was saved as written. Captured against the real built SPA with a one-off harness of the same shape as website/scripts/capture-blocked-link-chip-host-only.mjs (stub-dashboard-api.mjs fixtures; it asserts the notice and the kept segment are on the page and no streamed text is). Not committed: it would duplicate that script's capture loop.

Reloaded thread with a withheld segment, dark
Reloaded thread with a withheld segment, light

Related Issues

Closes #21582

Part of #20769 (this PR fixes the saved, copied and posted reply; #20817 finishes it at the stream, so the preview never shows more than the saved text)

Pattern harvest

Rule candidate: review-prompt
Pattern: text redacted in pieces is saved by redacting the whole raw text once, failing closed when that cannot be verified; never patch pieces back together with regex folds.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 15, 2026 11:41
@bolichen97
bolichen97 requested a review from buluoray October 15, 2026 11:41
@bolichen97
bolichen97 enabled auto-merge (squash) October 15, 2026 11:41
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/exfil.py

  • src/kiro_crew/security/redaction.py

  • @bolichen97 posted a complete reasoning template for a85cbad.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

UX-level review of a85cbad75054683738d952dab710300fe4c7948c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The new withheld notice looks like ordinary reply text, not a message from the app, and it doesn't say how much of the reply is missing.

Watch

  • The notice blends into the reply. The other redaction markers ([REDACTED: credential], [REDACTED: suspicious URL to …]) are matched by MARKER_RE in RedactionCards.tsx and shown as tags. The new _SEGMENT_UNCHECKED_TEXT string doesn't match that pattern, so it shows as plain bracketed text. The blind reader said it "could almost pass for something the assistant wrote itself", and in the light theme it's "plain dark-gray text… no box, color or icon". The reader also couldn't tell how much was hidden: "one sentence? most of the reply?". Severity is moderate: it only shows on a withheld segment, but there it is the whole message. The smallest fix is to extend the marker pattern so this notice gets its own tag, apart from the reply text.
  • The recovery step names something the screen doesn't. "Ask the agent to send it again" offers no button, and the reader noted that "'Agent' is also a different word for what the rest of the screen calls 'Kiro Crew'". On large-chunk backends a resend may be withheld again (the PR measured 7% for presigned links). Severity is low to moderate: it is friction on a path that is already rare.

Suggestions

  • In _SEGMENT_UNCHECKED_TEXT, lead with what happened and use the product's own words. For example: [REDACTED: part of this reply was hidden because it couldn't be checked for secrets. Ask Kiro Crew to resend it.]

[UX-REVIEWED] a85cbad

Description read

[DESCRIPTION-READ] 6434a7049a0b29bc8f7b14e0eb4535a0524f25cfa451309fdb17baa4d6129085

That sha256 names everything this verdict read: the PR description, plus the 5 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 Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a85cbad75054683738d952dab710300fe4c7948c — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check before merge: Slack replies are still redacted chunk by chunk (slack/handler_runtime/stream.py:724-733), so the Goal's "posted" holds only after #20817 lands.

What this change ships

Inventory (9 items) — 9 justified

Intent: a blocked link that streams in over several chunks is saved, copied and posted as one placeholder, with nothing of its query left behind. This is a FIX.

  1. A saved chat reply is now the whole raw reply redacted once, not the chunk-by-chunk pieces — justified
  2. A reply that can't be checked (too big, raw copy doesn't match, a pass raised, a removed value is back) is saved as a "withheld" notice — justified
  3. A reply is withheld if it shows any run of text the old chunk-by-chunk save would have hidden — justified
  4. Blocked-link records that quote text the old save hid are dropped, and their placeholder stays — justified
  5. A record that quotes a removed credential withholds the reply — justified
  6. A work ceiling on these checks, so a reply with many removed values can't stall the event loop — justified
  7. Every caller of the link pass now rewrites blocked links longest first, so a longer link's token tail can't survive (Exfil redaction keeps a token when a blocked URL is a prefix of another #21582) — justified
  8. Interrupted replies go through the same whole-text save — justified
  9. Two new optional arguments on the security API (removed_out=, defer_token_param), each with one consumer, which the description says can be deleted once Credential redactor keeps a link token that follows a '.' #21550 and Credential redaction keeps most of a second token glued to the first #21595 are fixed — justified

[FIRST-PRINCIPLES-REVIEWED] a85cbad

Description read

[DESCRIPTION-READ] 44c359388b931063980e8abfd0438ab616911a0993d041b260c573ad711ed2fa

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 Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of a85cbad75054683738d952dab710300fe4c7948c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The per-chunk StreamRedactor, which causes this leak, is still in place. The PR adds a large save-time checking layer on top of it, and the live stream still leaks until #20817.

Watch

  • This fixes the symptom. The description says "the five live StreamRedactor sites … still redact each chunk alone." The live stream still sends a cut link's query to every open tab; this PR only cleans the saved row. To hide that, _redact_segment runs four checks: _kept_removed_values, _saved_text_shows_more, _records_hold_removed_credential and _SEGMENT_CHECK_MAX_WORK. Every check compares against a per-delta pass that is known to be wrong. The description itself says they "can be deleted" only after Credential redactor keeps a link token that follows a '.' #21550, Credential redaction keeps most of a second token glued to the first #21595 and Subagent SSE tail, native card output and Slack answer stream redact each chunk alone, so a cut link leaks its query #20817 land. Until then, every new redaction rule has to keep this comparison layer correct too.
    Clears when: #20817 is linked as a merge-blocking follow-up and has an owner, and #21550/#21595 are tracked as the cleanup trigger for that scaffolding.
  • The default-refuse rule throws away replies without telling the user. Under _saved_text_shows_more, any whitespace run the whole-text pass shows that per-delta did not replaces the whole saved reply with _SEGMENT_UNCHECKED_TEXT. The description measures this at 7% of presigned-link replies on large-chunk backends. The user saw the reply stream in, and later finds it gone from history, copy and channel posts. The only signal is a log line.
    Clears when: the withheld rate is shown for benign replies on the large-chunk backends (opencode/codex fixtures), not only for kiro.

[DESIGN-REVIEWED] a85cbad

Description read

[DESCRIPTION-READ] c1a0ec4f5307644289565701ad34a0192e55aa02d6f6cbc779df8f2ec704df9d

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 Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

One advisory finding; nothing blocks the merge.

FINDING — src/kiro_crew/dashboard/chat_turn/segment_flush.py:415 — when a delta boundary cuts a blocked link whose record keeps its url (for example https://abc.ngrok.io/collect?d=hello-there-…, cut 30 characters before its end), the whole-text record's url is not in main and is not a substring of the shorter address the delta blocked. So field in main or any(field in address for address in addresses) drops the record. I reproduced it: the saved row holds the placeholder with blocked_links == [], so the reader gets no chip and no "open anyway" in exactly the cut-link case this change targets. Before this change that record was kept. → Fix: also accept a field that starts with a delta-blocked address when the rest of it appears in main (field.startswith(address) and field[len(address):] in main).

[OPUS-REVIEWED] a85cbad

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable a85cbad75054683738d952dab710300fe4c7948c: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a85cbad

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a85cbad75054683738d952dab710300fe4c7948c: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

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

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

Scope-Verdict: CONCERNS

TIGHTENING: The chat segment flush now redacts the slot's raw copy as one text, and falls back to withholding the whole reply instead of saving the per-delta text -- the one threat it refuses is a blocked link or credential that a delta boundary cut, leaving its tail in the saved row: + logger.warning("segment flush failed closed: %s", reason) / + return _SEGMENT_UNCHECKED_TEXT, [], [] in segment_flush._redact_segment. A related change in exfil.redact_exfiltration_urls_with_records (+ for matched in sorted(blocked, key=len, reverse=True):) rewrites blocked links longest first. It does not change which links are blocked.

ADJUDICATED: 16 candidates, 0 confirmed newly-refused
No rows came back confirmed. The shell deny composite (is_sensitive_bash_command, audit_bash_exfiltration, is_denied) is not changed by this diff:

  • audit_bash_exfiltration never calls redact_exfiltration_urls_with_records.
  • The new defer_token_param on redact_credentials_with_records defaults to False, and no hooks tier calls it.

The rows check that the URL-bearing shell operations near the changed link pass still behave as before. They do not measure the tightening itself.

PLATFORM COVERAGE: I wrote candidates for posix, windows and any.

  • posix: pytest, vitest, grep, curl, git clone, pip and a python3 -c check of the link pass.
  • windows: .venv\Scripts\python.exe pytest with \ separators, Select-String, curl.exe (because curl is a PowerShell alias), Invoke-WebRequest, and git clone to a drive-letter path.
  • any: gh api and kirocrew logs.

The diff adds no new path, separator, interpreter or env-var assumption. It hashes text as UTF-8 with surrogatepass and compares runs split on whitespace (\S+), and both behave the same on every host. One URL row probes the base link plus a longer link (.../pull/20805 and .../pull/20805/files), which is the case the longest-first rewrite reorders.

UNADJUDICATED: The fail-closed segment-save guard in dashboard/chat_turn/segment_flush._redact_segment. This is a dashboard-side save guard, so no shell verdict exists for it.

Call path: the model streams a text event. chat_runner._run_chat passes it to _redact_delta(event.text), then _accumulate_segment_raw(slot, raw, shown, removed) stores the raw copy, its SHA-256 hash and the removed values. At a segment cut, the turn end or an interrupt, _flush_segment (or the interrupted-body path at chat_runner.py:4747) calls _redact_segment(slot, turn.assistant_text). That function either saves the whole-text result or _SEGMENT_UNCHECKED_TEXT with no records.

Ordinary replies this can newly withhold, which I would have submitted if a classifier for this guard existed:

  • A reply over _SEGMENT_RAW_MAX_CHARS (2,000,000 chars), for example an agent dumping a large generated file or log into chat. Before this change the per-delta redacted text was saved; now the whole reply becomes the "reply withheld" notice whether or not it holds any secret. This is a narrowing I can argue but not confirm. Narrow it: past the cap, fall back to saving the per-delta text, as before.
  • A reply whose ordinary long token was cut by a delta boundary, such as a base64 blob, a long hash or a JWT-like test fixture. If one piece looked credential-shaped to the per-delta pass but the whole value does not, _kept_removed_values / _saved_text_shows_more refuse the save. The security doc names this as an accepted cost; it is listed here so the loss is on record.
  • A reply where a per-delta redaction tag changed the whitespace runs, for example a blocked link glued to prose that the per-delta pass split differently from the whole-text pass. Then _saved_text_shows_more returns True with nothing secret in the text.
  • A turn where something writes to turn.assistant_text without going through _accumulate_segment_raw. The hash check then reports "raw copy does not match the streamed text" and the reply is withheld. I found no such writer in the base tree's call sites, but none of the six base live StreamRedactor sites (the doc's list plus _wsred) can be checked from here.

Each of these is a legitimate reply lost to a guard no leg can classify, so this half stays CONCERNS.

[SCOPE-REVIEWED] a85cbad

@bolichen97
bolichen97 force-pushed the fix/stream-redact-url-tail-20769 branch from 5cf94e3 to d7b7019 Compare October 15, 2026 11:58
@bolichen97

bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: open-address hold in StreamRedactor

  • URL holdback makes the credential ceiling discard a clean URL span=236d69c2bf66

fixed in d7b7019: the open-address cut is applied only when no STRONG anchor is present and after STRONG classification, so it never sets the window a credential ceiling or fail-closed drop is measured from.
With a strong anchor the cut and caps are exactly main's.
Regression: TestSplitAddressRedaction::test_a_held_link_never_moves_the_credential_ceiling (4 KB clean link ending ?token=, step 64 and 10000) is red on 5cf94e3 and green on d7b7019.

@bolichen97

bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author
  • zero consumers: two new facade exports span=6d7ba59f70bd

fixed in d7b7019: both _EXPORTS rows are deleted. chat_runner imports fold_pieced_addresses from kiro_crew.security.exfil, and the tests import both names from there too.

@bolichen97

bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Build the address-end classes from one shared constant span=0d9ae4aee36c

fixed in d7b7019: exfil spells _URL_HOST, _URL_PATH_CHAR and URL_END_PUNCTUATION once; _ADDRESS_RUN and _PIECED_ADDRESS_RE are built from them.
_URL_RE keeps its literal spelling (its pattern is unchanged); test_the_folds_and_the_stream_hold_read_an_address_like_url_re pins the host group and path class inside _URL_RE.pattern and the stream hold's end set against the class, so any drift fails a test.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Two same-host chips side by side read as two separate removed links

rebutted: they are two removed links (report.csv and /other-a), so two chips is the true count; main showed one chip plus the second link's raw text.
Each chip names only the host and the card never presents the one record as the clicked link (MarkdownRenderer.blockedLinkOneOne.test.tsx); the chip rendering itself is unchanged by this PR.

@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 Oct 15, 2026
@bolichen97
bolichen97 force-pushed the fix/stream-redact-url-tail-20769 branch from d7b7019 to 3ef7154 Compare October 15, 2026 12:06
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • duplicate: URL_END_PUNCTUATION and _URL_END_CHARS spell the same set span=6f301aba5beb

fixed in 3ef7154: security._URL_END_CHARS is deleted; the stream hold reads exfil.URL_END_PUNCTUATION, and exfil._URL_PATH_CHAR is built from it, so the set is written once with two production readers.
The remaining test pins that one spelling to _URL_RE's own behaviour (every ASCII character), not two copies to each other.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Stream hold on open URLs and how fast link-heavy replies stream

rebutted: the hold covers only the characters of an address still open at the buffer end; text before it streams as before, and the address appears the moment a space or ) " ' > arrives, which is the same chunk in practice for markdown links and prose.
It is bounded at 4096 chars per address, and a held address over the bound is judged and emitted at once; TestSplitAddressRedaction::test_open_link_hold_is_bounded_and_loses_nothing pins the bound.
Main already held the same characters up to 512 (they are all credential-class), so a typical sub-512 link streams with the same latency as today.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • A same-host link with a redacted key now shows as a second chip

rebutted: two links were removed, so two host chips is the true count; on main the second link showed its session token and signature around a credential tag.
Each chip and its card render through the unchanged chip component; MarkdownRenderer.blockedLinkOneOne.test.tsx checks both chips name only the host and the card never claims the record as the clicked link.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Item 3, symptom-level: the saved text is still built from per-delta redaction span=dc216c2b6d42

rebutted (clears-when met: the description now says why): the streamed text differs from the raw copy on purpose (the options-footer reflow edits it before _redact_segment), and a per-delta pass can remove a value a whole-text pass keeps, so saving the raw copy's result could show text the stream never showed.
_wsred output is not the saved source either: it is cut per segment for the wire and never carries the reflow. Both folds only remove text, so neither can widen what is saved.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Item 5, two unfixed per-chunk siblings (subagent SSE tail, native card output) span=4a135190cf24

accepted-and-deferred to #20817 (deferred-finding, assigned, Due 2026-10-29), named in the description: route both through a per-stream StreamRedactor with a cut-link test.
They are separate streams with their own lifecycles; this PR's goal is the saved, copied and posted chat reply.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Say why a mismatch between the two copies cannot fall back to raw_redacted span=cbe9b5248146

rebutted in the description (What changed): the copies differ on purpose (the options-footer reflow) and a per-delta pass can remove more than a whole-text pass, so a fallback to raw_redacted could save text the stream withheld; a remove-only fold cannot.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Holding open links up to 4096 chars and link-heavy replies on Slack and other streams

rebutted: only an address still open at the buffer end is held; it is released at the first space or ) " ' >, so a link inside prose or markdown appears as soon as it is complete.
Main already held the same run up to 512 chars (URL characters are credential-class), so links under 512 stream as today; the 4096 bound only adds latency for a single longer link, which is the presigned-link case this fixes.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ee23001
  • What rule changed: no credential or link matcher changed. security/exfil.py rewrites its blocked links longest first after the loop (before: a global str.replace per match in match order) and gains the optional removed_out=; security/redaction.py redact_credentials_with_records gains the optional defer_token_param that redact_credentials already takes. dashboard/chat_runner.py saves a chat segment as one whole-text pass over the raw deltas under a default-refuse check, or a withheld notice.
  • Before -> after (what was allowed/blocked, now): before, a blocked link or key cut by a stream delta boundary was saved, copied and posted in pieces, so a presigned link's query could be saved; and a blocked link that prefixes a longer one left the longer one's token tail (also on main, one delta). After, the saved row is the raw text redacted once, kept only if every whitespace/bracket/quote-delimited run it shows (blocked-link domains included) appears in main's own per-delta save; nothing else vouches. Otherwise, or on no raw copy, hash mismatch, a raised pass, a kept removed value, a record quoting a removed credential, or the work ceiling, the segment is the withheld notice, never raw text. A blocked-link record is kept only for a placeholder the saved text holds and when it quotes only main's text or an address a delta blocked whole; else it is dropped and the placeholder stays.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a value a delta's redaction hid is saved in a chat row. Default refuse makes the save show no run main's save does not. Known narrow residual (Opus, non-blocking): a password made only of bracket/quote-separated pieces that the same reply also prints elsewhere, glued after a token across a cut. Accepted cost: withheld replies (below). No command, tool or login path is touched.
  • Evidence checked (which sandbox result proves it): test_chat_runner_coverage.py::TestBlockedLinkCardRecords (the Streaming redaction misses a presigned URL whose query tail arrives in a later chunk #20769 repro; the two-delta token-form test; every shape the pinned local reviewers and CI's GPT lane found over ten rounds, each red on the head before its fix) and test_redaction_blocked_links.py (the Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 repro, red on main). Pinned local GPT 6.1 and Opus 5.5 (agent kirocrew-research) PASS on this patch; Opus fuzzed text and records at delta sizes 2-500 with 0 new values saved. Measured chunk sizes: kiro-cli 480 chunks over 6 real turns, max 42; withheld at those sizes 0% for presigned, sink and plain link replies; large-chunk backend fixtures (opencode/pi/deepseek/codex) 7% presigned, 0% sink and plain; base64 blob 7 of 200.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, shell or command path changed.
    • Backward compatible (old config / old data / old callers still work, how checked): both new security/ arguments are optional; blocked links, warnings and records from redact_exfiltration_urls_with_records are unchanged apart from the longest-first rewrite (test_redaction_blocked_links.py); saved rows render as before. No config or schema change.
    • Existing tests (which suites passed on this head): on main 05c98db0c5 (patch unchanged from 3a03c33343): 602 passed in the chat runner, redaction, liveness and composition suites; scripts/local-gate.py backend related 1/3 29,306 passed, 2/3 46,426 passed and 7 failed in test_pi_gate_extension_mcp.py (a node subprocess through this host's mise shim times out; unrelated); black, isort, flake8, mypy, flake ratchet, semgrep and p/secrets clean.
  • How to undo: revert this one commit. No data migration; rows saved as the withheld notice stay as the notice.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 76207bf
  • What rule changed: no credential or link matcher changed. security/exfil.py rewrites its blocked links longest first after the loop (before: a global str.replace per match in match order) and gains the optional removed_out=; security/redaction.py redact_credentials_with_records gains the optional defer_token_param that redact_credentials already takes. dashboard/chat_runner.py saves a chat segment as one whole-text pass over the raw deltas under a default-refuse check, or a withheld notice.
  • Before -> after (what was allowed/blocked, now): before, a blocked link or key cut by a stream delta boundary was saved, copied and posted in pieces, so a presigned link's query could be saved; and a blocked link that prefixes a longer one left the longer one's token tail (also on main, one delta). After, the saved row is the raw text redacted once, kept only if every whitespace/bracket/quote-delimited run it shows (blocked-link domains included) appears in main's own per-delta save; nothing else vouches. Otherwise, or on no raw copy, hash mismatch, a raised pass, a kept removed value, a record quoting a removed credential, or the work ceiling, the segment is the withheld notice, never raw text. A blocked-link record is kept only for a placeholder the saved text holds and when it quotes only main's text or an address a delta blocked whole; else it is dropped and the placeholder stays.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a value a delta's redaction hid is saved in a chat row. Default refuse makes the save show no run main's save does not. Known narrow residual (Opus, non-blocking): a password made only of bracket/quote-separated pieces that the same reply also prints elsewhere, glued after a token across a cut. Accepted cost: withheld replies (below). No command, tool or login path is touched.
  • Evidence checked (which sandbox result proves it): test_chat_runner_coverage.py::TestBlockedLinkCardRecords (the Streaming redaction misses a presigned URL whose query tail arrives in a later chunk #20769 repro; the two-delta token-form test; every shape the pinned local reviewers and CI's GPT lane found over ten rounds, each red on the head before its fix) and test_redaction_blocked_links.py (the Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 repro, red on main). Pinned local GPT 6.1 and Opus 5.5 (agent kirocrew-research) PASS on this patch; Opus fuzzed text and records at delta sizes 2-500 with 0 new values saved. Measured chunk sizes: kiro-cli 480 chunks over 6 real turns, max 42; withheld at those sizes 0% for presigned, sink and plain link replies; large-chunk backend fixtures (opencode/pi/deepseek/codex) 7% presigned, 0% sink and plain; base64 blob 7 of 200.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, shell or command path changed.
    • Backward compatible (old config / old data / old callers still work, how checked): both new security/ arguments are optional; blocked links, warnings and records from redact_exfiltration_urls_with_records are unchanged apart from the longest-first rewrite (test_redaction_blocked_links.py); saved rows render as before. No config or schema change.
    • Existing tests (which suites passed on this head): on main 6dceb4e899 (src and docs unchanged from 3a03c33343; the test file builds its PEM and AKIA samples from pieces): 602 passed in the chat runner, redaction, liveness and composition suites; scripts/local-gate.py backend related 1/3 29,306 passed, 1/3 29,225, 2/3 46,364 passed and 7 failed in test_pi_gate_extension_mcp.py (a node subprocess through this host's mise shim times out; unrelated); black, isort, flake8, mypy, flake ratchet, semgrep and p/secrets clean.
  • How to undo: revert this one commit. No data migration; rows saved as the withheld notice stay as the notice.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a00ecfe
  • What rule changed: no credential or link matcher changed. security/exfil.py rewrites its blocked links longest first after the loop (before: a global str.replace per match in match order) and gains the optional removed_out=; security/redaction.py redact_credentials_with_records gains the optional defer_token_param that redact_credentials already takes. dashboard/chat_runner.py saves a chat segment as one whole-text pass over the raw deltas under a default-refuse check, or a withheld notice.
  • Before -> after (what was allowed/blocked, now): before, a blocked link or key cut by a stream delta boundary was saved, copied and posted in pieces, so a presigned link's query could be saved; and a blocked link that prefixes a longer one left the longer one's token tail (also on main, one delta). After, the saved row is the raw text redacted once, kept only if every whitespace/bracket/quote-delimited run it shows (blocked-link domains included) appears in main's own per-delta save; nothing else vouches. Otherwise, or on no raw copy, hash mismatch, a raised pass, a kept removed value, a record quoting a removed credential, or the work ceiling, the segment is the withheld notice, never raw text. A blocked-link record is kept only for a placeholder the saved text holds and when it quotes only main's text or an address a delta blocked whole; else it is dropped and the placeholder stays.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a value a delta's redaction hid is saved in a chat row. Default refuse makes the save show no run main's save does not. Runs split on whitespace only, so a password with brackets or quotes cannot be rebuilt from pieces the reply repeats elsewhere (CI GPT 6.1 on 76207bf00a). Accepted cost: withheld replies (below). No command, tool or login path is touched.
  • Evidence checked (which sandbox result proves it): test_chat_runner_coverage.py::TestBlockedLinkCardRecords (the Streaming redaction misses a presigned URL whose query tail arrives in a later chunk #20769 repro; the two-delta token-form test; every shape the pinned local reviewers and CI's GPT lane found over ten rounds, each red on the head before its fix) and test_redaction_blocked_links.py (the Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 repro, red on main). Pinned local GPT 6.1 and Opus 5.5 (agent kirocrew-research) PASS on this patch; Opus fuzzed text and records at delta sizes 2-500 with 0 new values saved. Measured chunk sizes: kiro-cli 480 chunks over 6 real turns, max 42; withheld at those sizes 0% for presigned, sink and plain link replies; large-chunk backend fixtures (opencode/pi/deepseek/codex) 7% presigned, 0% sink and plain; base64 blob 7 of 200.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, shell or command path changed.
    • Backward compatible (old config / old data / old callers still work, how checked): both new security/ arguments are optional; blocked links, warnings and records from redact_exfiltration_urls_with_records are unchanged apart from the longest-first rewrite (test_redaction_blocked_links.py); saved rows render as before. No config or schema change.
    • Existing tests (which suites passed on this head): on main dad71b7cf7 (patch unchanged from 991d41e2c0): 602 passed in the chat runner, redaction, liveness and composition suites; scripts/local-gate.py backend related 1/3 29,306 passed, 1/3 29,226, 2/3 46,364 passed and 7 failed in test_pi_gate_extension_mcp.py (a node subprocess through this host's mise shim times out; unrelated); black, isort, flake8, mypy, flake ratchet, semgrep and p/secrets clean.
  • How to undo: revert this one commit. No data migration; rows saved as the withheld notice stay as the notice.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=e41efc8682b1: Notice doesn't say what it replaced

needs-a-decision: the notice copy is user-visible text the maintainer ruling did not set. Proposed: [REDACTED: part of this reply was withheld because Kiro Crew could not check it for secrets. Ask again to see it.] (one constant, _SEGMENT_UNCHECKED_TEXT).
maintainer: take the proposed copy here, or keep the current text? Not changed until picked, since every new head reruns the security review rounds.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=b6ff45bbf724: Notice blends in, and the session list hides it

rebutted (disproportional here): a styled card for the notice and a session-preview hint are new dashboard UI in a security PR that changes no component. The notice opens with [REDACTED: like every other placeholder, in the saved row, a copy and a channel post. A card fits #20817's display follow-up.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=ae745efb9d7e: Rewrite the string to name the scope and the product

needs-a-decision: same question as span=e41efc8682b1; this suggestion is the proposed copy there.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

accepted by maintainer ruling: the default-refuse layer and its withheld rate are the accepted steady state until #21550 and #21595 land (the fail-closed reading of the 10-16 ruling: never mask a cut link, withhold instead).
the description's cost section records the measured rate: 0% of link replies at the chunk sizes kiro-cli streams (480 chunks over 6 real turns, max 42 chars), 7% of presigned-link replies at large-chunk backend sizes, base64 blob 7 of 200. #21550, #21595 and #20817 each list the symbols to delete.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=2a7b9cda65ec: Reply loss depends on an unpinned invariant

fixed (already pinned): test_a_normally_streamed_turn_never_saves_the_withheld_notice drives a real _run_chat turn and asserts the saved row is the reply, not the notice; with a transforming writer on turn.assistant_text it goes red (checked: patching the += safe_chunk line to transform the chunk fails it with raw copy does not match the streamed text).
every mismatch is also logged with its reason, segment flush failed closed: raw copy does not match the streamed text.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=73097d7757fe: Nothing tracks the scaffolding's removal

fixed in the trackers: #21550 and #21595 now list _saved_text_shows_more (with _blank_tags, _shows_only, _SEGMENT_RUN_RE, _LINK_PLACEHOLDER_RE), _links_main_shows, segment_removed, removed_out=, _kept_removed_values, _records_hold_removed_credential and _SEGMENT_CHECK_MAX_WORK as deletable once fixed; #20817 carries the same removal criteria in a comment, with the withheld rate at 0 as the done condition.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=36e404d5b45c: Run the persisted segment through the rolling StreamRedactor

rebutted (out of goal, already sequenced): a rolling cross-delta StreamRedactor is #20817's design, and the maintainer ruling on this PR orders #20817 to follow this merge. Building it here would move the live stream sites into this security PR; once it lands, the comparison here is deleted per the removal list.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d06b345
  • What rule changed: no credential or link matcher changed. security/exfil.py rewrites its blocked links longest first after the loop (before: a global str.replace per match in match order) and gains the optional removed_out=; security/redaction.py redact_credentials_with_records gains the optional defer_token_param that redact_credentials already takes. dashboard/chat_turn/segment_flush.py (where main moved the segment save; chat_runner.py keeps the call sites) saves a chat segment as one whole-text pass over the raw deltas under a default-refuse check, or a withheld notice.
  • Before -> after (what was allowed/blocked, now): before, a blocked link or key cut by a stream delta boundary was saved, copied and posted in pieces, so a presigned link's query could be saved; and a blocked link that prefixes a longer one left the longer one's token tail (also on main, one delta). After, the saved row is the raw text redacted once, kept only if every whitespace/bracket/quote-delimited run it shows (blocked-link domains included) appears in main's own per-delta save; nothing else vouches. Otherwise, or on no raw copy, hash mismatch, a raised pass, a kept removed value, a record quoting a removed credential, or the work ceiling, the segment is the withheld notice, never raw text. A blocked-link record is kept only for a placeholder the saved text holds and when it quotes only main's text or an address a delta blocked whole; else it is dropped and the placeholder stays.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a value a delta's redaction hid is saved in a chat row. Default refuse makes the save show no run main's save does not. Runs split on whitespace only, so a password with brackets or quotes cannot be rebuilt from pieces the reply repeats elsewhere (CI GPT 6.1 on 76207bf00a). Accepted cost: withheld replies (below). No command, tool or login path is touched.
  • Evidence checked (which sandbox result proves it): test_chat_runner_coverage.py::TestBlockedLinkCardRecords (the Streaming redaction misses a presigned URL whose query tail arrives in a later chunk #20769 repro; the two-delta token-form test; every shape the pinned local reviewers and CI's GPT lane found over ten rounds, each red on the head before its fix) and test_redaction_blocked_links.py (the Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 repro, red on main). Pinned local GPT 6.1 and Opus 5.5 (agent kirocrew-research) PASS on this patch; Opus fuzzed text and records at delta sizes 2-500 with 0 new values saved. Measured chunk sizes: kiro-cli 480 chunks over 6 real turns, max 42; withheld at those sizes 0% for presigned, sink and plain link replies; large-chunk backend fixtures (opencode/pi/deepseek/codex) 7% presigned, 0% sink and plain; base64 blob 7 of 200.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, shell or command path changed.
    • Backward compatible (old config / old data / old callers still work, how checked): both new security/ arguments are optional; blocked links, warnings and records from redact_exfiltration_urls_with_records are unchanged apart from the longest-first rewrite (test_redaction_blocked_links.py); saved rows render as before. No config or schema change.
    • Existing tests (which suites passed on this head): on main 4be3332429 (ported onto main's chat_turn/segment_flush.py split; every moved function AST-identical to 991d41e2c0): 487 related and 373 composition/surface tests passed; scripts/local-gate.py backend related 1/3 29,306 passed, 1/3 29,156, 2/3 44,870 passed and 7 failed in test_pi_gate_extension_mcp.py (a node subprocess through this host's mise shim times out; unrelated); black, isort, flake8, mypy, flake ratchet, semgrep and p/secrets clean.
  • How to undo: revert this one commit. No data migration; rows saved as the withheld notice stay as the notice.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=3f216771a535: reply withheld overstates what was hidden

needs-a-decision: the notice copy is user-visible text the maintainer ruling did not set. Proposed: [REDACTED: part of this reply was withheld because Kiro Crew could not check it for secrets. Ask again to see it.] (one constant, _SEGMENT_UNCHECKED_TEXT).
maintainer: take the proposed copy, or keep the current text? Not changed until picked, since every new head reruns the security review rounds.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=1a73df20e422: Notice reads as model prose

rebutted (disproportional here): a styled card for the notice is new dashboard UI in a security PR that changes no component; the notice opens with [REDACTED: like every other placeholder, in the saved row, a copy and a channel post. A card fits #20817's display follow-up.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=ee954608a8f6: The recovery step has no control

rebutted (out of goal): a retry button is new dashboard UI, which this security PR does not add; typing the request works (the review calls it friction, not failure). The notice copy question is span=3f216771a535.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

confirmed: the description lists #20817 as the blocking follow-up for the five live StreamRedactor sites, the maintainer ruling on this PR orders it to follow this merge, and #20817 carries the removal criteria for this save-time layer.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

confirmed: #21550 and #21595 each list the save-time checks to delete once fixed (_saved_text_shows_more with _blank_tags/_shows_only/_SEGMENT_RUN_RE/_LINK_PLACEHOLDER_RE, _links_main_shows, segment_removed, removed_out=, _kept_removed_values, _records_hold_removed_credential, _SEGMENT_CHECK_MAX_WORK); the 7% presigned withhold rate at large-chunk sizes is in the cost section.

[operator: bolichen97]

Chat text is redacted one streamed delta at a time, so a delta boundary
inside a blocked link's query left the rest of the query (session token,
signature) in the saved reply. The segment flush now saves the raw copy
of the same deltas, with the same footer reflow, redacted once as a
whole. A value a per-delta pass removed that the whole-text pass would
keep is masked with its tag first. The flush fails closed (a withheld
notice, no records) when there is no raw copy, the raw copy does not
hash to the streamed text, a pass raises, or a masked value is still
kept.
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a85cbad
  • What rule changed: no credential or link matcher changed. security/exfil.py rewrites its blocked links longest first after the loop (before: a global str.replace per match in match order) and gains the optional removed_out=; security/redaction.py redact_credentials_with_records gains the optional defer_token_param that redact_credentials already takes. dashboard/chat_turn/segment_flush.py (where main moved the segment save; chat_runner.py keeps the call sites) saves a chat segment as one whole-text pass over the raw deltas under a default-refuse check, or a withheld notice.
  • Before -> after (what was allowed/blocked, now): before, a blocked link or key cut by a stream delta boundary was saved, copied and posted in pieces, so a presigned link's query could be saved; and a blocked link that prefixes a longer one left the longer one's token tail (also on main, one delta). After, the saved row is the raw text redacted once, kept only if every whitespace/bracket/quote-delimited run it shows (blocked-link domains included) appears in main's own per-delta save; nothing else vouches. Otherwise, or on no raw copy, hash mismatch, a raised pass, a kept removed value, a record quoting a removed credential, or the work ceiling, the segment is the withheld notice, never raw text. A blocked-link record is kept only for a placeholder the saved text holds and when it quotes only main's text or an address a delta blocked whole; else it is dropped and the placeholder stays.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a value a delta's redaction hid is saved in a chat row. Default refuse makes the save show no run main's save does not. Runs split on whitespace only, so a password with brackets or quotes cannot be rebuilt from pieces the reply repeats elsewhere (CI GPT 6.1 on 76207bf00a). Accepted cost: withheld replies (below). No command, tool or login path is touched.
  • Evidence checked (which sandbox result proves it): test_chat_runner_coverage.py::TestBlockedLinkCardRecords (the Streaming redaction misses a presigned URL whose query tail arrives in a later chunk #20769 repro; the two-delta token-form test; every shape the pinned local reviewers and CI's GPT lane found over ten rounds, each red on the head before its fix) and test_redaction_blocked_links.py (the Exfil redaction keeps a token when a blocked URL is a prefix of another #21582 repro, red on main). Pinned local GPT 6.1 and Opus 5.5 (agent kirocrew-research) PASS on this patch; Opus fuzzed text and records at delta sizes 2-500 with 0 new values saved. Measured chunk sizes: kiro-cli 480 chunks over 6 real turns, max 42; withheld at those sizes 0% for presigned, sink and plain link replies; large-chunk backend fixtures (opencode/pi/deepseek/codex) 7% presigned, 0% sink and plain; base64 blob 7 of 200.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, shell or command path changed.
    • Backward compatible (old config / old data / old callers still work, how checked): both new security/ arguments are optional; blocked links, warnings and records from redact_exfiltration_urls_with_records are unchanged apart from the longest-first rewrite (test_redaction_blocked_links.py); saved rows render as before. No config or schema change.
    • Existing tests (which suites passed on this head): on main 52a302b914 (patch byte-identical to d06b345c5b; ported onto main's chat_turn/segment_flush.py split; every moved function AST-identical to 991d41e2c0): 487 related and 373 composition/surface tests passed; scripts/local-gate.py backend related 1/3 29,306 passed, 1/3 29,156, 2/3 44,892 passed and 7 failed in test_pi_gate_extension_mcp.py (a node subprocess through this host's mise shim times out; unrelated); black, isort, flake8, mypy, flake ratchet, semgrep and p/secrets clean.
  • How to undo: revert this one commit. No data migration; rows saved as the withheld notice stay as the notice.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=0403548d080e: The notice blends into the reply

rebutted (disproportional here): a tag style for the notice in RedactionCards.tsx is new dashboard UI in a security PR that changes no component. The notice opens with [REDACTED: like every other placeholder, in the saved row, a copy and a channel post. A tag fits #20817's display follow-up.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=ccd1c0d8b98b: The recovery step names something the screen doesn't

needs-a-decision: the notice copy is user-visible text the maintainer ruling did not set. Proposed: [REDACTED: part of this reply was hidden because it couldn't be checked for secrets. Ask Kiro Crew to resend it.] (one constant, _SEGMENT_UNCHECKED_TEXT). Not changed until a maintainer picks it, since every new head reruns the security review rounds.
a resend button is new UI and out of this PR's goal; on kiro-sized chunks a resend is withheld 0% of the time (measured).

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=0bdb2e22da68: Lead with what happened and use the product's own words

needs-a-decision: the notice copy is user-visible text the maintainer ruling did not set. Proposed: [REDACTED: part of this reply was hidden because it couldn't be checked for secrets. Ask Kiro Crew to resend it.] (one constant, _SEGMENT_UNCHECKED_TEXT). Not changed until a maintainer picks it, since every new head reruns the security review rounds.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=53d8ff05c15b: This fixes the symptom

already tracked: the description lists #20817 as the merge-blocking follow-up for the live StreamRedactor sites, and the maintainer ruling on this PR orders it to follow this merge. #21550, #21595 and #20817 each list the save-time checks to delete once fixed (the cleanup trigger). Owner assignment for #20817 is a maintainer call.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=bc9b65b5910f: The default-refuse rule throws away replies without telling the user

fixed in the description: the cost section already gives the rate on the large-chunk backend chunk sizes (the opencode/pi/deepseek/codex recorded fixtures), not only kiro: 7% of presigned-link replies, 0% of sink and plain link replies, base64 blob 7 of 200; kiro-sized chunks 0% for all three.
every withhold logs its reason (segment flush failed closed: <reason>), and the saved row shows the notice, so it is not silent.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Slack replies are still redacted chunk by chunk

confirmed: the description's open-exposure line names slack/handler_runtime/stream.py among the five live StreamRedactor sites left to #20817; this PR covers the dashboard chat reply and channel posts sent from the saved text, not the Slack live stream.

[operator: bolichen97]

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: readiness: passed, all checks green, mergeable, no changes requested.

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.

Exfil redaction keeps a token when a blocked URL is a prefix of another

3 participants