Skip to content

fix(security): restore every allowed link on a host - #20487

Merged
buluoray merged 1 commit into
mainfrom
fix/exfil-allow-multi-url
Oct 28, 2026
Merged

buluoray merged 1 commit into
mainfrom
fix/exfil-allow-multi-url

Conversation

@buluoray

@buluoray buluoray commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Changing the stored placeholder text or adding a positional index to it. The model sees placeholders on replay, the frontend chip parses them, and feat(security): name the rule that redacted a URL after its placeholder #14783 is reworking their wording.
  • Changing the blocked-link record shape. The backend (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.
  • Restoring a host whose placeholders and records disagree in count (an address repeated in the reply, a placeholder the model echoed in prose). That stays blocked, as on main.
  • Multi-address restore on rows saved before this PR. Those keep main's one-address rule.
  • The blocked-link card's per-entry Allow buttons and title (Blocked-link card does not reflect Allow across entries/title #18675).

What changed

Root cause. restore_allowed_links (src/kiro_crew/security/exfil.py) builds one domain -> url map 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_records writes 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 (url set) under a rule in ALLOWABLE_BLOCKED_LINK_RULES; the placeholder count equals the record count; and either ordered is set or all records keep one address (main's rule).
  • Read-back: each address put back must be exactly the _URL_RE match 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.
  • Order marker BLOCKED_LINKS_ORDERED_KEY ("blocked_links_ordered", defined in chat_utils_display.py, re-exported by chat_utils) is set beside blocked_links when 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 in chat_turn/turn_reply_seams.py), the regenerate path's newest variant, and _append_command_reply.
    • _redact_segment_text reports the order through an optional _ordered_out list. 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_segment passes on the order of whichever pass it saves (the whole-text pass, or the strict SRI pass). Its fail-closed paths save no records.
    • The marker moves with its records: variant_from_row copies it, adopt_variant_text replaces it with the adopted variant's own, and with_allowed_links_restored / _variant_for_emit pass it to restore_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_BUDGET 32,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_links revalidates 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 repro S 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-meta refuses 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_url and test_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: the S B C C repro 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 naming blocked_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

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners October 14, 2026 20:52
@buluoray
buluoray requested a review from mbriones98 October 14, 2026 20:52
@buluoray buluoray changed the title fix(security): restore every allowed link on a host, not only identical fix(security): restore every allowed link on a host Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/exfil.py

  • @buluoray posted a complete reasoning template for d1dad08.

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

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 734a801
  • What rule changed: restore_allowed_links (display-time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when it has several DIFFERENT recorded addresses in one reply, by pairing its placeholders with its records in first-appearance order; plus a new read-back check that refuses a host if any address put back does not read as one whole _URL_RE match where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the identical address; two different links on one allowed host stayed blocked. After, they are restored, each in its own place. Still blocked, as before: unallowed host, record with no kept address, rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch (echoed placeholder, repeated address). Newly blocked: a placeholder that stood for only a prefix of a longer URL (main would have put the recorded address there).
  • Worst case if wrong (breaks commands / leaks secret / locks user out): Two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is still one the redactor recorded for that host in that message and that bounded_blocked_links revalidates on serve; no address the reply did not write can appear, credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for sandbox (no command/sandbox rule touched). Unit evidence: test_restore_puts_back_two_different_links_on_one_host_each_in_its_place, test_restore_of_two_links_leaves_an_unallowed_host_and_a_withheld_record, test_restore_never_puts_an_address_where_only_part_of_it_stood, test_records_from_the_raw_copy_keep_the_order_the_reply_wrote_them all fail on origin/main and pass on this head; the read-back test also fails with only the read-back check removed.
  • No regression:
    • Tools still work (which tools/commands were run, result): N/A -- no tool path changed; black, flake8, isort, mypy clean on changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): Stored placeholder format and record shape unchanged, so old rows restore as before (existing identical-address and echoed-placeholder tests unchanged and passing). Only signature/callers are the two existing display paths in chat_utils, unchanged.
    • Existing tests (which suites passed on this head): 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_streaming_meta_redaction -- 2262 passed.
  • How to undo: Revert this commit; no data migration, and stored rows were never changed.

@buluoray
buluoray force-pushed the fix/exfil-allow-multi-url branch from 734a801 to a401f7e Compare October 14, 2026 21:23
@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a401f7e
  • What rule changed: restore_allowed_links (display-time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when it has several DIFFERENT recorded addresses in one reply, by pairing its placeholders with its records in first-appearance order; plus a new read-back check that refuses a host if any address put back does not read as one whole _URL_RE match where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the identical address; two different links on one allowed host stayed blocked. After, they are restored, each in its own place. Still blocked, as before: unallowed host, record with no kept address, rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch (echoed placeholder, repeated address). Newly blocked: a placeholder that stood for only a prefix of a longer URL (main would have put the recorded address there).
  • Worst case if wrong (breaks commands / leaks secret / locks user out): Two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is still one the redactor recorded for that host in that message and that bounded_blocked_links revalidates on serve; no address the reply did not write can appear, credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for sandbox (no command/sandbox rule touched). Unit evidence: test_restore_puts_back_two_different_links_on_one_host_each_in_its_place, test_restore_of_two_links_leaves_an_unallowed_host_and_a_withheld_record, test_restore_never_puts_an_address_where_only_part_of_it_stood, test_records_from_the_raw_copy_keep_the_order_the_reply_wrote_them all fail on origin/main and pass on this head; the read-back test also fails with only the read-back check removed.
  • No regression:
    • Tools still work (which tools/commands were run, result): N/A -- no tool path changed; black, flake8, isort, mypy clean on changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): Stored placeholder format and record shape unchanged, so old rows restore as before (existing identical-address and echoed-placeholder tests unchanged and passing). Only signature/callers are the two existing display paths in chat_utils, unchanged.
    • Existing tests (which suites passed on this head): 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_streaming_meta_redaction -- 2262 passed; test_security_gate_liveness passes with the package line budget raised by 13 (29,181 -> 29,194), justified in its comment.
  • How to undo: Revert this commit; no data migration, and stored rows were never changed.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision d1dad0804a2a41882b17e2f226692eb8cd11c920 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

First-Principles-Verdict: PASS

Nothing blocks. 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

  • Item 5 — zero consumers: chat_runner.py adds BLOCKED_LINKS_ORDERED_KEY to its chat_utils re-export block. Grepping BLOCKED_LINKS_ORDERED_KEY finds 0 production readers through chat_runner; the only reader is test/test_chat_runner_coverage.py:968,1009. Subtraction: drop the chat_runner.py:277 re-export and have the test import it from chat_utils.

What this change ships

Inventory (6 items) — 5 justified

Intent: 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.

  1. Allow for this host now restores several different blocked links on one host, each in its own place — justified
  2. New rows carry an optional blocked_links_ordered meta flag that says their records are in reply order — justified
  3. A restored address must be the whole URL that starts where it lands; this also applies to rows saved before this PR — justified
  4. The order flag moves with its records into and out of regenerate variants — justified
  5. BLOCKED_LINKS_ORDERED_KEY is re-exported from chat_runner — zero consumers, only tests read it
  6. The security-gate line budget goes from 32,188 to 32,213, with the reason recorded beside it — justified

[FIRST-PRINCIPLES-REVIEWED] d1dad08

Description read

[DESCRIPTION-READ] a7337deccb48f11eaaa463f5327a3c3591c497e2eef656b82127c48a949e13c5

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 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

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

  • The order marker is a second invariant stored beside blocked_links. Every writer that later builds records from more than one redaction pass has to clear it. Today that rests on the five listed writers keeping to it, and no single owner enforces it.

[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 .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 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] d1dad08

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

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

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d1dad08

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

@buluoray
buluoray force-pushed the fix/exfil-allow-multi-url branch from a401f7e to 992630e Compare October 14, 2026 22:35
@buluoray

Copy link
Copy Markdown
Contributor Author

GPT 6.1 BLOCKING exfil.py:1555 (legacy records restore under the wrong labels): fixed in 992630e.

Confirmed: rows saved before this change can hold a host's records as [B, A] (old _redact_segment appended raw-copy records after the text's own), and ordinal pairing restored them swapped. Reproduced on a401f7e through _prepare_messages with a row {"blocked_links": [B, A]}: the content came back as First B then A end.
Fix, as suggested: new rows carry meta["blocked_links_ordered"] = True (chat_utils.BLOCKED_LINKS_ORDERED_KEY), written by _segment_row_meta on both write paths only when _redact_segment vouches for the order. It is withheld when a merged record has no place in the raw copy's order. restore_allowed_links(..., ordered=) pairs several different addresses only when the marker is present. An unmarked (legacy) row keeps the previous rule: restored only when every record for the host has the same address.
The marker sits beside the records, not inside them, because both revalidate_blocked_link and the frontend validator require the exact record keys. It moves with its records: variant_from_row copies it, adopt_variant_text replaces it with the adopted variant's own (so an older variant never inherits a newer row's marker), the regenerate path writes it on the newest variant, and both restore call sites (with_allowed_links_restored, _variant_for_emit) read it.
Regression tests: test_restore_pairs_different_links_only_on_a_row_that_vouches_their_order (legacy row stays blocked, marked row restored, legacy one-address row unchanged), test_the_order_marker_moves_with_the_records_it_describes, TestBlockedLinkCardRecords::test_records_with_no_place_in_the_raw_copy_are_not_vouched_in_order. Mutations each fail one of them: drop the ordered gate, leave a stale marker on adopt, never clear the order on the fallback, drop the variant copy.
The "legacy swap" residual is removed from the PR description: it is now closed.

@buluoray

Copy link
Copy Markdown
Contributor Author

Opus FINDING exfil.py:154 (read-back misses a placeholder inside an earlier URL): fixed in 992630e.

Confirmed with the exact repro: A = https://h/x?q=<250 chars>, B = https://h/r?next= + A redacts to P and https://h/r?next=P with records [A, B]. On a401f7e the restore rendered https://h/r?next=https://h/r?next=https://h/x?q=…, a link the reply never wrote.
Fix: the read-back now requires each address to be exactly the _URL_RE match that starts where it lands, taken from one finditer over the restored text (starts.get(at) != url fails the host). A placeholder inside a URL that begins earlier never starts a match, so that host keeps its placeholders. The same check still refuses the prefix-of-a-longer-link case (test_restore_never_puts_an_address_where_only_part_of_it_stood stays green).
Regression test: test_restore_never_puts_an_address_inside_another_url. It fails on a401f7e, and it fails again when the check is reverted to the from-at _URL_RE.match.

@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 14, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 992630e
  • What rule changed: restore_allowed_links (display-time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when it has several DIFFERENT recorded addresses in one reply, by pairing its placeholders with its records in first-appearance order -- but only on a row whose meta carries blocked_links_ordered: True, which the writer sets when _redact_segment vouches the records are in reply order. Unmarked (pre-existing) rows keep main's rule: restored only when every record for the host keeps one address. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the identical address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked, as before: unallowed host, record with no kept address, rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, and any unmarked row with different addresses. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL (e.g. https://h/r?next=<placeholder>), which main's one-address path would have filled in.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): Two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is still one the redactor recorded for that host in that message and that bounded_blocked_links revalidates on serve; no address the reply did not write can appear, credential checks are untouched, and /api/link-meta still refuses restored links. A forged marker on an edited transcript line grants nothing a forged record list does not already. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for sandbox (no command/sandbox rule touched). Unit evidence: test_restore_pairs_different_links_only_on_a_row_that_vouches_their_order (legacy [B, A] row shown swapped on a401f7e, stays blocked now), test_restore_never_puts_an_address_inside_another_url (nested repro rendered a never-written link on a401f7e), test_the_order_marker_moves_with_the_records_it_describes, test_records_with_no_place_in_the_raw_copy_are_not_vouched_in_order; each of five guard mutations fails exactly one of them.
  • No regression:
    • Tools still work (which tools/commands were run, result): N/A -- no tool path changed; black, isort, flake8, mypy clean on changed files.
    • Backward compatible (old config / old data / old callers still work, how checked): Stored placeholder format and record shape unchanged (the marker sits beside the records, so revalidate_blocked_link and the frontend key check are unaffected). Old rows restore exactly as on main (test_restore_pairs_different_links_only_on_a_row_that_vouches_their_order pins an unmarked one-address row), except the read-back refusals above. New keyword arguments default to the old behaviour.
    • Existing tests (which suites passed on this head): 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_streaming_meta_redaction, test_security_gate_liveness, test_chat_utils* -- 2323 passed, 1 skipped; plus test_leaked_toolcall_notice, test_rewind_native_fork, test_slot_render_context_key, test_source_pin_budget, test_token_param_stream_deferral, test_chat_persistence* -- 188 passed. Package line budget 29,181 -> 29,196, reason in its comment.
  • How to undo: Revert this commit; no data migration. Rows written with the marker are read by the old code as ordinary rows (the extra meta key is ignored).

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

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

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

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

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 exfil.restore_allowed_links. A restored address must now read back as the whole _URL_RE match at the position where it lands, including on the old one-address path. The shell classifier never sees that check, so it is listed under UNADJUDICATED below. No redaction rule, pattern or threshold changed, and I found no legitimate reply shape that the new check would block where it was shown before.

TIGHTENING: the restore read-back in restore_allowed_links, which now covers every host it restores, not only the new multi-address hosts. It blocks a placeholder from being swapped for an address that never stood whole at that spot: one placeholder that covered only part of a longer link, or one inside another URL, so the reader would see a link the reply never wrote. Hunk: starts = {r.start(): r.group(0) for r in _URL_RE.finditer(out)} / failed = {d for d, at, url in placed if starts.get(at) != url} / domains -= failed (src/kiro_crew/security/exfil.py, @@ -924,56 +935,70 @@).

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 \ separators, curl.exe with a double-quoted URL) and any (kirocrew manifest --url, GitHub REST list with two query parameters). The diff adds no assumption about paths, separators, interpreters, executables or environment variables. It compares strings against _URL_RE, which works the same on every host. So these rows only check that the shell exfil tier, which imports the changed module, behaves the same on each host. No assumed platform was left without a candidate.

UNADJUDICATED: Guard: the read-back loop in security/exfil.restore_allowed_links, reached at display time only. Call paths: chat_utils._prepare_messages / state._broadcast_chat_message → chat_utils_display.with_allowed_links_restored → restore_allowed_links(text, bounded_blocked_links(meta["blocked_links"]), current_scoped_exempt_hosts(), ordered=meta.get("blocked_links_ordered") is True). Regenerate variants take the same route through chat_utils_display._variant_for_emit. The classifier settles shell command lines only, so nothing here got a verdict. The reply inputs I would have submitted, each on a host the workspace has allowed via Allow for this host:
(a) a stored one-address row (no blocked_links_ordered marker) whose placeholder is followed directly by . , ] or [ with no space, such as a link at the end of a sentence;
(b) a markdown link [label](<long-query URL>) on an old row;
(c) a restored link followed directly by another host's placeholder or a credential tag;
(d) an old row with one address that is also a prefix of a longer blocked address on a different host.
In (a), (b) and (d) the original text was matched by the same _URL_RE (path class [^\s)"'>]). That means any trailing ., ,, [ or ] is already part of the recorded url, and restoring rebuilds the same span. For (c), the original would have been one merged match, not two records. I expect all four to come back as before, but no script confirmed that. One user-visible effect is real but untested: an old row whose text was later changed next to a placeholder (for example a placeholder the model echoed with URL text after it, as in the {tag}&page=2 case) used to restore and now keeps its link blocked. The new tests pin that as intended.

[SCOPE-REVIEWED] d1dad08

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 15, 2026

@CrysisDeu CrysisDeu 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.

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.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 15, 2026
mbriones98
mbriones98 previously approved these changes Oct 15, 2026

@mbriones98 mbriones98 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.

Checks green and readiness passed at 992630e; no behavior change.

@CrysisDeu CrysisDeu 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.

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_RE match" (Finding 1), plus the wording nit alongside it.

Why this is a comment rather than an approve:

  1. Merge conflict in 3 files — chat_runner.py, segment_flush.py (imports), and the liveness budget. exfil.py itself is clean. Rebase needed.
  2. Sensitive Change Review is red — the template needs to be filled for 8727c5bf (or the rebased head).
  3. A stale CHANGES_REQUESTED from @iamwhatever at 4ba1fbfe is 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.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as 8727c5bf / 344747ef; only the package line budget line changed in the rebase.

Sensitive change review

  • Head commit: 0c42d73
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with match-order replace and the redactor's _ordered_out guard removed, test_a_link_carrying_another_blocked_link_never_lands_in_its_place fails (with the guard kept, it passes); with the command-reply marker write disabled, test_a_command_reply_vouches_the_order_of_its_links fails.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 344747ef shows only the package line budget re-based onto main (32,530 + 25 = 32,555).
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: reply to @iamwhatever's REQUEST_CHANGES review at 4ba1fbf, re-checked on the rebased head 0c42d738c7c4a426370f46483a78f371d7be1b96 (one commit on main badd8f5a). The code is unchanged from 8727c5bf / 344747ef; git range-diff shows only the package line budget re-based (32,530 + 25 = 32,555). The PR now closes #24131.

1. S B C C: a redirect carrying the sink address put back where C stood. Fixed.

  • On main the redactor replaces longest first, so B gets its own placeholder. allowed.example then has three placeholders (B C C) for two records [B, C], and the count check refuses the host.
  • Your suggested guard is in as well: when a recorded address is already gone from the text before its own replace, _ordered_out becomes [False] and the row is not marked, so different addresses do not pair.
  • Test: TestBlockedLinkCardRecords::test_a_link_carrying_another_blocked_link_never_lands_in_its_place runs your exact reply through the streamed-delta flush; the restored text equals the redacted text, and neither B nor S appears.
  • Measured on this head: with the replace switched back to match order (as on 4ba1fbf) and the guard kept, the test passes; with the guard also removed, it fails. So the guard alone closes the hole even if the replace order regresses.

2. First Principles: _append_command_reply never writes blocked_links_ordered. Fixed. A command reply is one _redact_segment_text pass, so it writes the marker under the same rule (chat_turn/segment_flush.py). Test: test_slash_command_redaction_records.py::test_a_command_reply_vouches_the_order_of_its_links; it fails when the marker write is disabled.

3. Security Scope disposition scoped to 32771775. The Security Scope lane ran on this head and passes, so no disposition is needed.

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.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as 0c42d738c7; only the package line budget line changed in the rebase onto main ebaeffb35c.

Sensitive change review

  • Head commit: 03f097b
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with the command-reply marker write set to False, test_a_command_reply_vouches_the_order_of_its_links fails; with the streamed-flush marker write set to False, TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order fails.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 0c42d738c7 shows only the package line budget re-based onto main (32,601 + 25 = 32,626).
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as 03f097b7f8 (git range-diff shows the commit identical); this rebase onto main 908099fc26 only picks up #24292's test fix.

Sensitive change review

  • Head commit: 2449e60
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with the command-reply marker write set to False, test_a_command_reply_vouches_the_order_of_its_links fails; with the streamed-flush marker write set to False, TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order fails.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 03f097b7f8 shows the commit unchanged; the package line budget stays 32,601 + 25 = 32,626.
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as 2449e60606 (git range-diff shows only the package line budget comment and value changed); this rebase onto main cca03bd528 resolves one conflict in test_security_gate_liveness.py, where main's own +12 budget note and this PR's +25 note both landed on the same line.

Sensitive change review

  • Head commit: e94efca
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with _redact_segment_text never reporting _ordered_out = [True], test_a_command_reply_vouches_the_order_of_its_links and TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order both fail; with _segment_row_meta never writing the marker, the latter fails. Each run otherwise green (96 and 97 passed).
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 2449e60606 shows only the budget line changed; the package line budget is now main's 32,613 + 25 = 32,638.
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as e94efca2a9 (git range-diff shows the commit identical, =); this rebase onto main 8f18fd5add only picks up #24485, which drops the three stale strict xfails in test_crew_log_fullscan_guard.py that made shard 2 red on the previous head.

Sensitive change review

  • Head commit: 9f38295
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with _redact_segment_text never reporting _ordered_out = [True], test_a_command_reply_vouches_the_order_of_its_links and TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order both fail; with _segment_row_meta never writing the marker, the latter fails. Each run otherwise green (96 and 97 passed).
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 2449e60606 shows only the budget line changed; the package line budget is now main's 32,613 + 25 = 32,638.
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: template for the rebased head. The code is the same as 9f38295a4a (git range-diff shows the commit identical, =); this rebase onto main dbf207ccc2 only picks up #24531, which fixes the two test_telegram_dispatcher.py tests that made shard 4 red on the previous head.

Sensitive change review

  • Head commit: 610f5c9
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with _redact_segment_text never reporting _ordered_out = [True], test_a_command_reply_vouches_the_order_of_its_links and TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order both fail; with _segment_row_meta never writing the marker, the latter fails. Each run otherwise green (96 and 97 passed).
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 2449e60606 shows only the budget line changed; the package line budget is now main's 32,613 + 25 = 32,638.
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

CrysisDeu
CrysisDeu previously approved these changes Oct 27, 2026

@CrysisDeu CrysisDeu 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.

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:

  1. LOW — the S B C sibling case is still not in test/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.
  2. INFO — exfil.py:756-757 docstring should say the [False] guard is a backstop for a replace-order change (your own measurement confirms it is).
  3. NIT — chat_utils_display.py:155,985 leave blocked_links_ordered behind when blocked_links is 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.

iamwhatever
iamwhatever previously approved these changes Oct 27, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

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 S B C sibling regression test and a softer "Every refusal on main still refuses" line. Add it with the rebase, or open an issue and link it in the description.

To clear: rebase onto main. The rebased head needs a fresh review.

— crew-pr-reviewer (r128)

@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 83c05df
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with _redact_segment_text never reporting _ordered_out = [True], test_a_command_reply_vouches_the_order_of_its_links and TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order both fail; with _segment_row_meta never writing the marker, the latter fails. Each run otherwise green (96 and 97 passed).
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 610f5c9f2a shows only the budget line changed; the package line budget is now main's 32,616 + 25 = 32,641.
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@CrysisDeu CrysisDeu 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.

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:

  1. Sensitive Change Review is red: the 14:55Z template names 83c05df7, not 8add3e06. Re-post it for this head.
  2. @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 C regression test next to S 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.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 8add3e0.

This PR changes which redacted links are restored for display (exfil.py and the marker writers in the dashboard), so it stays with a human reviewer. The r105 defect stays fixed: the longest-first replace marks the row unordered, and the restore re-checks every placed address. The branch is rebased and mergeable, and the AI lanes pass.

What still blocks:

  • Sensitive Change Review is red on this head: the latest template names 83c05df. Re-post it for 8add3e0.
  • The two r128 asks, which @CrysisDeu now requires in the same push, are still open: add the S B C regression test next to S B C C (B and C restored in place, S's placeholder kept), and reword "Every refusal on main still refuses" in the security reasoning, because main refused any host with different addresses and an ordered row now restores them.

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)

@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8add3e0
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with _redact_segment_text never reporting _ordered_out = [True], test_a_command_reply_vouches_the_order_of_its_links and TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order both fail; with _segment_row_meta never writing the marker, the latter fails. Each run otherwise green (96 and 97 passed).
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 83c05df72b shows only the budget line changed; the package line budget is now 32,660, the package's line count on this head.
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 8add3e0.

This PR changes which redacted links are restored for display (restore_allowed_links and the blocked_links_ordered writers in the dashboard), so it stays with a human reviewer. I found no new defect: the r105 fix holds (longest-first replace), every refusal path returns the original text, and the read-back re-checks every placed address. The Sensitive Change Review template for this head is now posted and green, every check passes, and the AI lanes pass.

Still open, both asked in this PR by @CrysisDeu as maintainer:

  • Add the S B C regression test next to S B C C (B and C restored in place, S's placeholder kept). It is not in the tree.
  • Reword "Every refusal on main still refuses" in the security reasoning. Main refused any host with different addresses, and an ordered row now restores them.

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.
@buluoray

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d1dad08
  • What rule changed: exfil.restore_allowed_links (display time only; nothing about what is redacted or stored changes). A host the reader allowed is now restored when one reply holds several DIFFERENT recorded addresses on it, by pairing its placeholders with its records in first-appearance order. This happens only on a row whose meta carries blocked_links_ordered: True. The writer sets it when one redaction pass wrote the records and every record kept its own placeholder. Unmarked rows keep main's one-address rule. A read-back refuses a host unless each address put back is exactly the _URL_RE match that STARTS where it lands.
  • Before -> after (what was allowed/blocked, now): Before, an allowed host was restored only when every record for it had the same address. After, a marked row with different addresses on one allowed host is restored, each in its place. Still blocked: an unallowed host, a withheld address, a rule outside ALLOWABLE_BLOCKED_LINK_RULES, any placeholder/record count mismatch, an unmarked row with different addresses, and the review's S B C C reply. Newly blocked: a placeholder that stood for only a prefix of a longer URL, or sat inside another URL. The allow rule itself is not widened: only hosts the reader allowed, and only addresses recorded for that host in that message.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): two addresses from the same reply, on the same host the reader allowed, shown in each other's places. Every restored address is one the redactor recorded for that host in that message, revalidated by bounded_blocked_links on every serve. Credential checks are untouched, and /api/link-meta still refuses restored links. No command, secret or login path is involved.
  • Evidence checked (which sandbox result proves it): N/A for the sandbox (no command or sandbox rule touched). Unit evidence on this head: test_redaction_allow.py (pairing, legacy-row gate, marker movement, nested and prefix read-back), TestBlockedLinkCardRecords (streamed-delta flush marks the row; S B C C stays blocked; PEM swallow clears the marker), test_a_command_reply_vouches_the_order_of_its_links. Mutations run on this head: with _redact_segment_text never reporting _ordered_out = [True], test_a_command_reply_vouches_the_order_of_its_links and TestBlockedLinkCardRecords::test_two_links_on_one_host_cut_across_deltas_are_vouched_in_order both fail; with _segment_row_meta never writing the marker, the latter fails. Each run otherwise green (96 and 97 passed).
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool or command path changed. 661 tests pass on this head across test_redaction_allow, test_redaction_blocked_links, test_security_gate_liveness, test_slash_command_redaction_records, test_chat_runner_base_surface, test_chat_runner_coverage, test_display_time_redaction, test_exfil_carveouts, test_redaction_mirror_parity, test_streaming_meta_redaction, test_source_pin_budget.
    • Backward compatible (old config/data still works): yes. Placeholder text and record shape are unchanged. The meta key is optional and read only when it is literally True. Old rows restore under main's rule, except the read-back refusals above (fail closed).
    • Existing tests (which suite, result): the suites above pass locally; git range-diff against 8add3e069f shows only the budget line changed (main +8 and this PR +25 merged, budget now 32,668).
  • How to undo: revert the commit. Rows written with the marker then restore under main's one-address rule, since the key is ignored.

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.

Allow for this host does not restore every blocked link on that host

4 participants