Repository navigation
fix(security): redact a streamed link cut inside its query as one link - #20805
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of 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
Suggestions
[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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: Slack replies are still redacted chunk by chunk ( What this change shipsInventory (9 items) — 9 justifiedIntent: 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.
[FIRST-PRINCIPLES-REVIEWED] a85cbad Description read[DESCRIPTION-READ] 44c359388b931063980e8abfd0438ab616911a0993d041b260c573ad711ed2fa That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The per-chunk Watch
[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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsOne 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 [OPUS-REVIEWED] a85cbad Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: 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: ADJUDICATED: 16 candidates, 0 confirmed newly-refused
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.
The diff adds no new path, separator, interpreter or env-var assumption. It hashes text as UTF-8 with UNADJUDICATED: The fail-closed segment-save guard in Call path: the model streams a text event. Ordinary replies this can newly withhold, which I would have submitted if a classifier for this guard existed:
Each of these is a legitimate reply lost to a guard no leg can classify, so this half stays CONCERNS. [SCOPE-REVIEWED] a85cbad |
5cf94e3 to
d7b7019
Compare
|
self-added: yes
|
|
|
|
d7b7019 to
3ef7154
Compare
|
|
|
|
|
|
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
Sensitive change review
|
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[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.
Sensitive change review
|
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
[operator: bolichen97] |
chenmingwei23
left a comment
There was a problem hiding this comment.
Approving: readiness: passed, all checks green, mergeable, no changes requested.
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
blockedLinkQueryTail). This PR does not depend on it; rows saved before this change still carry a tail, so it stays useful for them.StreamRedactoris 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(inchat_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, andredact_credentials_with_recordstakesdefer_token_param.exfil.pynow 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 on5ae2569fad). 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._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)..(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_credentialand_SEGMENT_CHECK_MAX_WORKcan be deleted._SEGMENT_UNCHECKED_TEXTwith 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-linkurl/path/domain, credentialview_command/profile_command/source fields) holds a removed value, or the checks would pass_SEGMENT_CHECK_MAX_WORK._reflow_label_and_auditruns inside_redact_segment._ChatSlotgainssegment_shown_shaandsegment_removed(memory only);_CREDENTIAL_TAG_REis removed. Package line budget 29,574 -> 29,590.Open until #20817 (blocking follow-up): the five live
StreamRedactorsites (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.tsxandMarkdownRenderer.blockedLinkOneOne.test.tsxchange: 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_segmentoutput; test_presigned_link_cut_by_a_delta_saves_as_one_placeholderReader: 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::TestBlockedLinkCardRecordsunless named;test_a_disagreeing_raw_copy_is_not_trustedandtest_records_come_from_the_one_whole_text_passare intest_chat_runner_coverage_output.py::TestFlushSegment.test_presigned_link_cut_by_a_delta_saves_as_one_placeholder(seven cuts, six red on main) andtest_presigned_links_cut_anywhere_save_no_query(three layouts, every 7th cut plus 2-5 cut sets).&, 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) andtest_a_hostname_shaped_like_a_key_does_not_shelter_a_cut_query(every 5th cut).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 reachedmeta.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_chatturn 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 on75f564b6c2), thea-connection-string-a-glued-token-swallowedcase (Opus), and intest_redaction_blocked_links.pytest_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 semgrepp/secretsclean (0 findings); the chat runner, segment, redaction, liveness and composition suites 659 passed. Local review: GPT 6.1 and Opus 5.5 pinned reviewers (agentkirocrew-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 on76207bf00a(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.pyresults 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.mjsfixtures; 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.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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)