Repository navigation
fix(security): restore every allowed link on a host - #20487
Conversation
Sensitive change review
|
734a801 to
a401f7e
Compare
Sensitive change review
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Issue #24131 and a test that fails on base back the fix. The only spare surface is a re-export that just tests read. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: when a user clicks Allow for this host, every blocked link on that host comes back, even when one reply holds several different addresses on it. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] d1dad08 Description read[DESCRIPTION-READ] a7337deccb48f11eaaa463f5327a3c3591c497e2eef656b82127c48a949e13c5 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: pairing placeholders by order only on rows marked as written in reply order, plus the count check and URL read-back, fixes the host-level refusal without changing the stored format. Notes
[DESIGN-REVIEWED] d1dad08 Description read[DESCRIPTION-READ] cd4e59ff959d622fcb0627fb449ed6e7dcf1e01f0a9b319066bc932de72cd778 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 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: |
a401f7e to
992630e
Compare
|
GPT 6.1 BLOCKING
|
|
Opus FINDING
|
Sensitive change review
|
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The only part of this change that refuses more is a display-time check inside TIGHTENING: the restore read-back in ADJUDICATED: 8 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: I wrote candidates for posix (pytest run of the touched suites, curl to a dashboard link with a short query, git log of the exfil module), windows (pytest and git diff with UNADJUDICATED: Guard: the read-back loop in [SCOPE-REVIEWED] d1dad08 |
CrysisDeu
left a comment
There was a problem hiding this comment.
Reviewed head 992630e. The over-blocking fix is sound in the common case, but it introduces an under-blocking path, so holding:
BLOCKER, exfil.py:1540-1541 vs :1422-1423: restore_allowed_links pairs placeholders to records by position whenever count matches and ordered=True (the default on every live row, chat_runner.py:4598). The redactor does result.replace(matched, placeholder) in match order, so when a later URL contains an earlier blocked URL, the inner replace rewrites the inside of the outer URL first and the outer URL's own replace finds nothing: it gets a record but zero placeholders. Repro with a plain model reply, no forged data: S = https://sink.other.net/x?d=<260 chars>, B = https://allowed.example/r?next=S, C = https://allowed.example/a?q=<250 chars>, text S B C C. Records for allowed.example = [B, C]; placeholders = 2 (both from C). Count matches, user clicks Allow, placeholder #1 becomes B, and the reply now shows https://allowed.example/r?next=https://sink.other.net/...: an address on a host the user never allowed. Main refused this (len(urls) == 1), so "every refusal on main still refuses" is false here. Fix either side: in the redactor, when matched not in result before the replace, withhold the record's url so it can never pair; or in restore_allowed_links, refuse a host when any record URL contains a second _URL_RE match. Add the S B C C repro as a test that fails on this head.
Process: the Opus lane raised exactly this on head 992630e (2026-10-14 22:08Z) and it is unanswered; your dispositions target a401f7e.
Minor: the read-back at :1566-1567 now refuses rows main restored (placeholder followed by [REDACTED: ...] or any non-space text); fail-closed, acceptable, but say so in the spec since the description claims legacy rows restore exactly as main.
Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.
mbriones98
left a comment
There was a problem hiding this comment.
Checks green and readiness passed at 992630e; no behavior change.
992630e to
fd3489e
Compare
CrysisDeu
left a comment
There was a problem hiding this comment.
Re-review at 8727c5bf: previous BLOCKER is fixed — code-level approve, not yet mergeable
My earlier blocker (nested-URL "S B C C" wrong-position pairing) is resolved at the root: exfil.py:877-885 now replaces longest-first, the _ordered_out[:] = [False] guard at :881-884 holds, and the host filter at :965-977 refuses on a 3≠2 count mismatch. The exact repro is covered by test/test_chat_runner_coverage.py:935-951 test_a_link_carrying_another_blocked_link_never_lands_in_its_place.
Remaining findings are 1 LOW, 1 INFO, 2 NITs — none blocking:
- Add a test for "record URL itself contains a second
_URL_REmatch" (Finding 1), plus the wording nit alongside it.
Why this is a comment rather than an approve:
- Merge conflict in 3 files —
chat_runner.py,segment_flush.py(imports), and the liveness budget.exfil.pyitself is clean. Rebase needed. - Sensitive Change Review is red — the template needs to be filled for
8727c5bf(or the rebased head). - A stale CHANGES_REQUESTED from @iamwhatever at
4ba1fbfeis still outstanding; it predates the fix and needs dismissing or re-review by them.
Once 1–3 are done I will approve.
Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.
8727c5b to
344747e
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: reply to @iamwhatever's REQUEST_CHANGES review at 1.
2. First Principles: 3. Security Scope disposition scoped to 4. Sensitive Change Review red. The template for this head is posted; the check passes. Nothing in this change widens the allow rule: only hosts the reader allowed, and only addresses recorded for that host in that message, each proven to stand where it is put back. All five AI lanes pass on this head. Re-requesting your review. |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as Sensitive change review
|
CrysisDeu
left a comment
There was a problem hiding this comment.
Re-review at 610f5c9f: Approve (code-level)
610f5c9f is a clean rebase of 8727c5bf — git range-diff shows only the two import hunks and the liveness budget moved; exfil.py, chat_utils_display.py, turn_reply_seams.py, security.md and both test files are byte-identical patches. The three conflict sites landed correctly (segment_flush.py:24 in the direct chat_utils import block, chat_runner.py:270-273, _PACKAGE_LINE_BUDGET = 32_638 = base + 25 with ledger comment). Sensitive Change Review and Security Scope now PASS. I re-walked S B C C, S B C, lone B and placeholder-inside-URL against the new head: same outcomes as at 8727c5bf, no new under-blocking path.
Still open from my last comment, all non-blocking:
- LOW — the
S B Csibling case is still not intest/test_chat_runner_coverage.py:958; please add it (asserting B restored in place, S placeholder kept) and soften the PR-body line "Every refusal on main still refuses" to "every refusal that protected a placeholder's position still refuses". Fine as a follow-up. - INFO —
exfil.py:756-757docstring should say the[False]guard is a backstop for a replace-order change (your own measurement confirms it is). - NIT —
chat_utils_display.py:155,985leaveblocked_links_orderedbehind whenblocked_linksis popped.
What still blocks the merge button is @iamwhatever's CHANGES_REQUESTED at 4ba1fbfe, which predates the fix; it needs their re-review or a maintainer dismissal.
Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.
|
HOLD at 610f5c9. The branch conflicts with main again, so it needs another rebase. PR Readiness is still re-checking on this head. The defect behind our r105 change request is fixed. The longest-first replace marks the row unordered when a blocked link was rewritten inside a longer one, and the restore re-checks every placed address against a URL match at its position. All AI lanes pass, and @CrysisDeu has approved this head. One small item is still open: @CrysisDeu's LOW asks for the To clear: rebase onto main. The rebased head needs a fresh review. — crew-pr-reviewer (r128) |
Sensitive change review
|
CrysisDeu
left a comment
There was a problem hiding this comment.
Comment (not approving yet) at 8add3e06. Code-level this is still an approve; two things have to land first, and because auto-merge is on an approval would merge the moment the template is re-posted.
Delta vs 610f5c9f (which I approved 02:46Z): a rebase, one changed line (_PACKAGE_LINE_BUDGET -> 32_660). No code change; none of main's new commits touch the blocked-link path. Re-verified the invariants at this head: longest-first replace exfil.py:881-885, host filter refuses on count mismatch :969-976, placeholder guard :995-1001, the nested-URL S B C C test at test/test_chat_runner_coverage.py:973; 185 tests pass locally plus 14 adversarial inputs of our own, none restored a link on a non-allowed host or in another link's place. First Principles / Opus / GPT / Security Scope green, no self-override.
Before I approve:
- Sensitive Change Review is red: the 14:55Z template names
83c05df7, not8add3e06. Re-post it for this head. - @iamwhatever's two asks from 06:45Z are still open and the 14:55Z comment does not answer them. As maintainer I want both in the same push as the template, not deferred: (a) add the
S B Cregression test next toS B C C(assert B and C restored in place, S's placeholder kept); (b) reword "Every refusal on main still refuses" in the security reasoning to "every refusal that protected a placeholder's position still refuses" (main refused any host with different addresses,len(urls)==1; an ordered row now restores them, so the sentence is not literally true and it is the audit record).
Optional: exfil.py:756-758 docstring could note the [False] guard is a backstop behind longest-first; chat_utils_display.py:150-155, 981-985 pops blocked_links but leaves blocked_links_ordered in meta (harmless).
Note for the record: iamwhatever's old CHANGES_REQUESTED at 4ba1fbfe was superseded by their 06:02Z approval, so once (1)+(2) are in, one approval merges this.
Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.
|
HOLD at 8add3e0. This PR changes which redacted links are restored for display ( What still blocks:
Auto-merge is on, so a single approval would merge it once the template is re-posted. The new head will need a fresh review. — crew-pr-reviewer (r129) |
Sensitive change review
|
|
HOLD at 8add3e0. This PR changes which redacted links are restored for display ( Still open, both asked in this PR by @CrysisDeu as maintainer:
Auto-merge is on, so one approval would merge this. The push that adds the test will need a fresh review. — crew-pr-reviewer (r130) |
…al ones Allow for this host did nothing when one reply held two different addresses on that host (two dashboard links that differ only in their query): restore_allowed_links restored a host only when every record for it kept the same address, because a placeholder names only its host. Pair a host's placeholders with its records by order instead. Records are written in first-appearance order and a repeated address yields one record, so exactly one placeholder per record means each address stood in the text once, in that order. Every existing refusal stays: an unallowed host, a withheld address, a rule the allow does not relax, or any count mismatch (an echoed placeholder, a repeat) keeps all of that host's placeholders. A read-back check also refuses a host unless each address put back is the whole URL match that STARTS where it lands, so an address is never put back over part of a longer link or inside another one. Rows saved before this change may hold a host's records out of reply order, so several different addresses on one host pair only on a row marked blocked_links_ordered. The segment flush, the interrupted-reply path, the regenerate variant and a local command's reply set it when one redaction pass wrote the records and every record kept a placeholder of its own: a link rewritten inside a longer one, or a placeholder a credential span (a PEM block) swallowed, leaves the row unmarked. The marker moves with its records into and out of regenerate variants. An unmarked row keeps the old rule. The stored placeholder format is unchanged. Ported onto the split chat_turn/segment_flush.py and chat_utils_display.py owners.
Sensitive change review
|
Problem / Motivation
Goal: Allow for this host shows every blocked link on that host again, including when one reply holds several different addresses on it.
A user clicked Allow for this host on a blocked link and nothing changed. The reply held two links to the same dashboard host whose queries differed. The host went onto the allow-list, but both links stayed as
[REDACTED: suspicious URL to <host>]placeholders.Why it matters
Replies that link several views of one tool (dashboards, query consoles, reports) are common, and their long queries trip the length heuristic. For those replies Allow for this host is a button that does nothing, and the user has no other way to open the links in place.
Not a goal
revalidate_blocked_link) and the frontend (RedactionCards.tsx) both require its exact keys, so the order marker lives beside the records in the row's meta instead.What changed
Root cause.
restore_allowed_links(src/kiro_crew/security/exfil.py) builds onedomain -> urlmap and swaps every placeholder for that host's single address. A placeholder carries only its host, so when a host had two different recorded addresses, main refused the whole host (len(urls) == 1).Approach. Pair by order, but only where the order is known.
redact_exfiltration_urls_with_recordswrites records in first-appearance order, and a repeated address produces one record. So if the text holds exactly one placeholder per record for a host, the n-th placeholder is the n-th record. Rows saved before this PR can't promise that, so the row now says whether its records are in reply order. A row without that marker keeps main's rule.Change.
restore_allowed_links(text, records, hosts, *, ordered=False)restores a host only when: it is allowed; every record keeps its address (urlset) under a rule inALLOWABLE_BLOCKED_LINK_RULES; the placeholder count equals the record count; and eitherorderedis set or all records keep one address (main's rule)._URL_REmatch that starts where it lands. This refuses a placeholder that stood for only the prefix of a longer link, and a placeholder inside a URL that starts earlier (https://h/r?next=<placeholder>). It also covers main's one-address path.BLOCKED_LINKS_ORDERED_KEY("blocked_links_ordered", defined inchat_utils_display.py, re-exported bychat_utils) is set besideblocked_linkswhen one redaction pass wrote the records and every record kept a placeholder of its own. Writers:_segment_row_meta(segment flush and interrupted-reply path inchat_turn/turn_reply_seams.py), the regenerate path's newest variant, and_append_command_reply._redact_segment_textreports the order through an optional_ordered_outlist. It is cleared when the credential pass swallows a link placeholder (a PEM block around a link), and when the redactor finds a blocked address already rewritten inside a longer one (redact_exfiltration_urls_with_records(_ordered_out=))._redact_segmentpasses on the order of whichever pass it saves (the whole-text pass, or the strict SRI pass). Its fail-closed paths save no records.variant_from_rowcopies it,adopt_variant_textreplaces it with the adopted variant's own, andwith_allowed_links_restored/_variant_for_emitpass it torestore_allowed_links.docs/system-specs/modules/security.md: the blocked-link bullet describes the pairing rule, the marker and the read-back.test/test_security_gate_liveness.py:_PACKAGE_LINE_BUDGET32,188 -> 32,213, reason recorded beside it.test/test_chat_runner_base_surface.py: the three moved signatures gain their keyword-only, defaulted parameter.Security reasoning. Every address restored is one the redactor recorded for that host in that message, and
bounded_blocked_linksrevalidates every record on each serve, as before. Every refusal on main still refuses. The one new thing is a choice between several recorded addresses on the same allowed host. The marker, the count check and the read-back together make sure each address goes back where it stood and never into another link. The review reproS B C C(a redirect on the allowed host carrying a sink link) stays blocked. A forged marker on a hand-edited transcript line gives nothing a forged record list doesn't already give. Restored links are still never previewed (/api/link-metarefuses them).Backwards compatibility
Compatible. The stored placeholder format and the record shape are unchanged. A row written before this PR is restored exactly as main restores it, except that the read-back now refuses an address that would run into the text after it or sit inside another URL. The new meta key is optional; readers treat it as absent unless it is literally
True. Removes nothing.Tests
test/test_redaction_allow.py:test_restore_puts_back_two_different_links_on_one_host_each_in_its_place: fails on main.test_restore_pairs_different_links_only_on_a_row_that_vouches_their_order: an unmarked[second, first]row stays blocked, a marked row is restored, an unmarked one-address row is restored as before.test_the_order_marker_moves_with_the_records_it_describes.test_restore_never_puts_an_address_inside_another_urlandtest_restore_never_puts_an_address_where_only_part_of_it_stood: hand-built nested/prefix shapes stay blocked; the redactor's own output for the same replies comes back exactly.test_restore_of_two_links_leaves_an_unallowed_host_and_a_withheld_record,test_restore_leaves_a_host_when_a_repeat_hides_which_placeholder_is_which.test/test_chat_runner_coverage.py::TestBlockedLinkCardRecords:test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order: streamed deltas cut both links; the row is marked and both come back.test_a_link_carrying_another_blocked_link_never_lands_in_its_place: theS B C Crepro from review stays blocked.test_a_link_swallowed_by_a_credential_span_is_not_vouched_in_order: a link inside a PEM block clears the marker.test/test_slash_command_redaction_records.py::test_a_command_reply_vouches_the_order_of_its_links.Ran 1773 tests across
test_redaction_allow,test_redaction_blocked_links,test_display_time_redaction,test_exfil_carveouts,test_security,test_chat_runner_coverage,test_redaction_mirror_parity,test_chat_runner_composition_contract,test_chat_runner_base_surface,test_streaming_meta_redaction,test_security_gate_liveness,test_slash_command_redaction_records,test_source_pin_budget,test_chat_utils*,test_chat_persistence*and every test file namingblocked_links/variant_from_row: all pass. black, isort, flake8 and mypy are clean on the changed files.Manual verification
N/A. The change is in pure functions and the row-meta write and read paths; the tests drive them with the real redactor and the streamed-delta flush.
Related Issues
Closes #24131
Related: #18675 (card UI around Allow, untouched here), #14783 (placeholder wording, independent).
Pattern harvest
Not generalizable: the defect came from this one function refusing to pair placeholders that carry no index.
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.