Skip to content

feat(security): explain a blocked link instead of a bare placeholder - #13192

Closed
buluoray wants to merge 2 commits into
feat/redaction-renderer-hard-rulesfrom
feat/redaction-blocked-link-chip
Closed

buluoray wants to merge 2 commits into
feat/redaction-renderer-hard-rulesfrom
feat/redaction-blocked-link-chip

Conversation

@buluoray

@buluoray buluoray commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

When the exfiltration check blocks a URL, the reader is left with plain text naming only the site: [REDACTED: suspicious URL to example.com]. It cannot be selected, it does not say why the link was blocked, and it gives the owner no way to judge a false positive. The rest of the URL is discarded before the message is written (security/exfil.py replaces the whole match with the site name), so nothing a renderer can reach explains the block.

Why it matters

A protection that cannot explain itself reads as a malfunction. The most common blocked link is a long query string, and long query strings are exactly where false positives live — a wiki link whose title is CJK percent-encodes into twenty-plus consecutive %XX groups. Today the owner cannot tell that case from a real exfiltration attempt, because the only thing on screen is a host name.

What changed (motivation → approach → change)

This retains STRUCTURE and never the query value. The rule for what may be kept is that only what the removers themselves would pass is kept: a path is kept only when the path ALONE fails to trip the URL warning AND survives credential redaction unchanged, because a link can smuggle data in its path as readily as in its query. The query is described by its length and never stored.

Keeping this does not feed the link back to the model. The replay the model receives is built from role and message text only, and that text is re-run through both removers before injection, so a detail kept in a message's meta is never part of what the model reads. What it does cost is recorded rather than glossed: a link judged suspicious now sits in the saved conversation instead of being destroyed.

The records and the redaction come out of ONE loop. redact_exfiltration_urls_with_records holds the body and redact_exfiltration_urls becomes a thin wrapper, so no existing caller changes and two scans cannot disagree about which URL was blocked.

Records carry no positional index on purpose. The placeholder names only the domain, so two different URLs on one host produce byte-identical placeholders and an index could attach one link's path to another. The chip pairs by domain, and shows the host and reason alone when a host has several differing records — the degraded case is honest rather than confidently wrong.

Every record read back from meta is re-validated. A transcript line is attacker-writable, so revalidate_blocked_link re-checks the exact key set, a strict host, a [a-z0-9_] rule id, a non-negative count, and a path that still passes both removers under the strictest posture available (is_https=False, no port — those parameters only ever unlock exemptions inside the warning, so re-checking as plain http can only reject more). A record that fails is dropped on its own; its siblings stand.

Two readers need the records and both get them from that one scan. The saved entry carries them, and the memoised front door copies them onto the live row, because the display path hands the ROW's meta to the redactor and a cache hit never runs the body — without that copy the chip would appear on a later load rather than on the turn that produced it. A rehydrated row holds the placeholder rather than the URL, so a rescan of it finds nothing: content survives a reopen because redaction is idempotent, records are derived, so they are carried forward while the content still shows a placeholder.

The chip is injected after sanitize. A rehype text-node pass runs after rehypeSanitize (like the streaming plugins), so blocked-link stays out of the agent-influenceable tag allowlist and a literal <blocked-link> written in prose is still escaped by the sanitizer that ran before it. A remark plugin was rejected for exactly that reason. The chip is never an anchor and never navigates; its border is dashed in the warning token, deliberately unlike the solid remote-media chip, because something is missing rather than loadable. Inspect explains the rule in plain language and states that the query was not kept — never "hidden" — so nobody hunts for a reveal that does not exist.

Copy URL and Open once are deliberately absent. They need the query value, and keeping that puts sending it one confirmation away; the RFC records them as a separate decision.

Strings ship in all 14 locales. The count is interpolated as {{chars}} rather than {{count}}: a base-only key with count makes i18next look for plural forms that do not exist, which is a latent trap rather than a live bug.

Backwards compatibility

redact_exfiltration_urls keeps its signature and behaviour, so every existing caller is untouched; the records variant is additive. A transcript written before this change has no blocked_links and renders exactly as it does today — the chip needs a record, so its absence degrades to the current plain placeholder. The new meta key is dropped entirely when nothing was blocked.

Tests

Backend (test/test_redaction_blocked_links.py, new): records match the redaction one-for-one; a repeated URL yields one record; records carry no positional field; a clean path is kept; a path that itself trips the rule is not; a path carrying a credential is not; query_chars counts the query and no record contains any substring of its value; the existing two-tuple caller is unaffected; the persisted entry carries the records and omits the key when clean; the user branch stays unredacted; the row gains the records and a cache HIT carries them to a second byte-identical row while a clean row is left alone; a reopened session keeps its records and drops them without a placeholder; a carried record is still re-validated, with tampered siblings dropped individually.

Frontend (website/src/test/MarkdownRenderer.blockedLink.test.tsx, new): the chip replaces the placeholder and leaves surrounding prose intact; several placeholders in one message; the degraded multi-record case; path omitted when null; the char count shown only when positive; the chip is never an anchor; Inspect states the query was not kept.

Gates run locally: 1505 backend tests, 1411 frontend tests (i18n + MarkdownRenderer suites), tsc -p tsconfig.app.json, eslint, npm run i18n:check (19 checks), black + baseline gates, comment-history, isort, flake8, mypy.

Manual verification

The visual states are rendered from this revision in Storybook (see Screenshots). What is still outstanding is the live one: a real blocked link in a real session on a running gateway, which no unit test and no story can stand in for because it exercises the redactor, the persistence attach point and the display path together. Tracked with the other live redaction checks in #12699.

Related Issues

Rollout step 3 of the design in docs/request-for-change/rfc-redaction-explain-and-reveal.md. Stacked on feat/redaction-renderer-hard-rules (#12684), which ships the RFC and step 1; this branch builds against that renderer and should merge after it.

Screenshots

Rendered from this revision through the repo's own Storybook (src/stories/BlockedLinkChip.stories.tsx, new), which mounts the real MarkdownRenderer with the real theme rather than an invented approximation. A live-gateway capture is a separate pending item — see Manual verification.

Every state in dark mode: one record with its retained path and what became of the address's trailing characters, the chip in flowing prose, a long retained path, two differing records on one host degrading to host-and-reason, the no-record fallback that stays plain text, and the chip beside the remote-media chip it must not be mistaken for. That last pairing is the point of the wording: the media chip holds something back and offers to load it, this chip states a removal, so the two say different words for different outcomes.

chip-states-dark

The disclosure open. Three separate facts on three lines — why the rule fired, that the removed characters were not kept, and the rule id — because run together they read as one sentence trailing off into an identifier. The id is labelled as an id and promises nothing further: telling a reader to report a mistake while naming no place to report it is a promise the chip cannot keep. The chevron is what says "this expands" before the reader risks a click, and it rotates with the aria-expanded state the button already announces.

chip-why-open

One chip per reason sentence the panel can state, all four open at once. Each rule gets its own sentence: the encoding rules do not borrow the credential one, because a long run of escaped characters is also what an ordinary non-Latin page title turns into and calling that a credential would accuse the reader's own content; and the two query rules differ, because length is about how much was there while pattern is about what it looked like. Every rule id shown is one the redactor actually emits from trace() in security/exfil.py.

chip-every-reason

The one case with no single answer: two records on one host that disagree on the rule. The panel states the generic reason and prints NO id line, because the only id it could print is one the redactor never emits — an owner searching for it would find nothing, which is the id line's one job failed exactly where the records conflict.

chip-degraded-open

The same states in light mode, which is where the dashed warning border has to stay legible against a warm subtle fill and still read as a different kind of thing from the neutral solid chip.

chip-states-light

What the captures and the reviews caught, fixed before this revision: the disclosure was text-accent hover:underline, this app's anchor styling on a chip that deliberately never navigates (now static main text with accent on hover only, pinned by a test); the panel ran its three facts together on one line; the rule-to-reason map sent the two encoding rules to the credential sentence; the chip body offered a pointer cursor while only the disclosure is interactive; the reader-facing copy asked for "query string", a term the chip itself never teaches; the label and its control used two different verbs for one event; and the degraded panel printed a fabricated rule id. Each of those is pinned by a test so the capture and the code cannot drift apart again.

Getting a Storybook render to paint at all needed a one-line fix to .storybook/vite.config.ts — it had no @tailwindcss/vite plugin while its docstring claimed Tailwind came from the package root via PostCSS, which this package does not have, so every story rendered as unstyled text. That fix is infrastructure rather than part of this change, so it sits on the base PR (#12684) where the first story landed; this branch inherits it and its own diff carries only the chip.

@buluoray
buluoray requested review from a team and krishdhasmana and removed request for a team September 23, 2026 21:59
@buluoray
buluoray force-pushed the feat/redaction-renderer-hard-rules branch from 79346ce to c280274 Compare September 23, 2026 22:20
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

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

UX-Verdict: CONCERNS

Degraded multi-link chip never says several links were merged — the blind reader couldn't tell if the second blocked link had simply vanished.

Watch

  • Degraded state (differing records on one host) drops path, count and rule id but adds no line saying why: the reader saw "Two links, blocked for different reasons:" and had "no idea whether the two blocked links were collapsed into this one notice or the second is simply not shown" (shot-04). The audience for this panel is exactly the owner judging a false positive, and the vaguer text reads as the system knowing less, not withholding deliberately. Rare case × real confusion × every occurrence → CONCERNS. Smallest fix: one panel line in the degraded branch, e.g. "Several different links to this site were removed; their details differ."

Suggestions

  • blocked_link_rule ("Rule id: exfil_query_length"): the reader said it "means nothing to me… I don't know what I could do with them." State its job in the line, e.g. "Rule id (for reporting a mistaken block): …".
  • "Link removed" beside a still-visible address made the reader think everything was deleted "yet part of the address is still shown" (blind read, "removed doing two jobs"); consider blocked_link_label → "Link removed — site kept" or similar to resolve the tension at the label.

[UX-REVIEWED] a8250ab

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify the live-gateway capture tracked in #12699 — the redactor → persistence → broadcast → chip seam is only exercised per-segment by unit tests here.

[DESIGN-REVIEWED] a8250ab

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🔴 BLOCK

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

First-Principles-Verdict: BLOCK

The new default chip rendering and newly persisted blocked-link records rest on an RFC the base records as draft — a proposal, not a decision.

Not justified as shipped

  • Item 1 — product-shape, no recorded decision: the description's own provenance ("Rollout step 3 of the design in docs/request-for-change/rfc-redaction-explain-and-reveal.md") points at a base-list entry reading draft.
    Clears when: that RFC is accepted/in-progress/partial/implemented on the base branch and the author pushes or rebases so the run reads a base carrying it, or a maintainer records /ai-review override first-principles a8250ab09afd7a001bcc489ace09b9835486df9d: <decision> (on a fork PR the override is not consumed — merge the RFC status first, or a maintainer pushes this branch to this repository).
  • Item 2 — product-shape, no recorded decision: "a link judged suspicious now sits in the saved conversation instead of being destroyed" — a changed persistence default for everyone, on the same draft RFC.
    Clears when: same record as Item 1.

What this change ships

Inventory (10 items) — 8 justified

Intent: let the owner of a chat see why a link was blocked and judge a false positive, instead of a bare [REDACTED…] placeholder — an ADDITION.

  1. A blocked link now renders by default as a "Link removed" chip with host, kept path, removed-char count and a "Why removed?" panel — product-shape without recorded decision (base RFC is draft)
  2. The saved conversation now retains a structure record (host, rule id, path, query length) per blocked link, by default — product-shape without recorded decision (same draft RFC)
  3. Regenerating or switching reply variants carries each variant's records with its text — justified
  4. Records read back from a transcript are re-validated and capped at 32, tampered ones dropped individually — justified
  5. A placeholder inside a link, code block, or pre stays plain text — justified
  6. Several differing blocked URLs on one host degrade the chip to host and reason only — justified
  7. Transcripts written before this change keep today's plain placeholder — justified
  8. Ten new strings in all 14 locales — justified
  9. Two new public security exports (redact_exfiltration_urls_with_records, bounded_blocked_links); existing callers untouched (counted consumers: 1 + wrapper, and 2 — chat_persistence, chat_utils) — justified
  10. Storybook stories covering every chip state — justified

Blockers

  • product-shape change without accepted RFC (Items 1–2). The base RFC status list reads docs/request-for-change/rfc-redaction-explain-and-reveal.md:status: draft, and the description grounds the shape in exactly that document ("Rollout step 3 of the design in…", "the RFC records them as a separate decision") while noting it is "Stacked on feat(security): redaction that explains itself (RFC prototype C+A) #12684, which ships the RFC" — a decision proposed beside the change, not one the repository recorded. The items change what everyone gets without choosing: the default rendering of blocked links and what the saved transcript retains about them, with no flag and no old-default path for new messages. No subtraction resolves this; the missing thing is the record.
    Clears when: the RFC covering this shape is merged non-draft on the base branch and the author pushes or rebases, or a maintainer records /ai-review override first-principles a8250ab09afd7a001bcc489ace09b9835486df9d: <decision>; on a fork pull request, merge the RFC status to base first or have a maintainer push this branch to this repository.

[FIRST-PRINCIPLES-REVIEWED] a8250ab

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging a8250ab09afd7a001bcc489ace09b9835486df9d. 2 of 2 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/security/exfil.py:1117 -- Partially encoded bare credentials survive retained paths
if redact_credentials(path)[0] != path:
Partially percent-encoded credential + long query -> blocked-link record retains path -> dashboard exposes credential bytes.
Anchor: backend-security-controls
Fix: Reject paths when any bounded percent-decoded form triggers credential redaction.

BLOCKING -- website/src/pages/chat/AssistantMessage.tsx:506 -- Local variant switches retain the previous variant’s link metadata (origin: validation)
<MarkdownRenderer ... blockedLinks={blockedLinks} />
Older regenerated row + local version arrow -> content changes via variants[localIdx] -> chip shows stale or missing link details.
Anchor: residual/crash-data-loss-corruption
Fix: Select blocked_links from the locally selected variant alongside its content.

[BLOCK-MERGE] a8250ab
[GPT-REVIEWED] a8250ab

Adjudication (Opus 5) — is blocking on each finding proportionate?

F1 — src/kiro_crew/security/exfil.py:1117
Harm rung: UNBOUNDED (credential bytes survive a redaction control into a retained, persisted, rendered field). Conditions confirmed: the retained-path gate applies redact_credentials to the RAW path only (exfil.py:1119), while the decode loop that does examine percent-decoded forms tests only _HARD_CREDENTIAL_RE/_contains_fixed_credential (exfil.py:934-936) — neither covers a bare entropy secret — and _EXFIL_PERCENT_RE needs a long consecutive octet run (exfil.py:958, per the comment at 943-945), so a few scattered %XX escapes clear all three. The path is then written into the record (exfil.py:1323) and the read-back re-check reuses the same raw-only rule (exfil.py:1222), so reload does not correct it. The text reaching this function is model/tool-authored and attacker-influenceable, so partially encoding a secret is a deliberate, cheap evasion rather than an extreme coincidence — no rarity argument is available.

F2 — website/src/pages/chat/AssistantMessage.tsx:506
Conditions confirmed: onSwitchVariant is passed only for the last text row (ChatPage.tsx:5759), so every older regenerated row takes the local-paging branch, where effectiveContent switches to variants[localIdx].content (AssistantMessage.tsx:200) while blockedLinks stays the message-level meta.blocked_links prop (AssistantMessage.tsx:101, 506) and variants carries no per-variant records (type at AssistantMessage.tsx:101). Self-correction exists — localIdx resets on content/variant-count change (AssistantMessage.tsx:196) and paging back restores agreement — and every rendered path already passed both removers, so nothing unredacted appears. But the reaching combination is an ordinary user action on an ordinary row, not extreme timing or unproducible input, so the rarity record FLAG requires cannot be completed.

[ADJUDICATION] a8250ab09afd7a001bcc489ace09b9835486df9d total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] a8250ab09afd7a001bcc489ace09b9835486df9d

[ADJUDICATION-FENCED] a8250ab09afd7a001bcc489ace09b9835486df9d fenced=2 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/security/exfil.py:1117 -- The retained-path gate credential-checks only the raw path while the decoded-form checks omit the bare-secret classifier, and attacker-influenced text can produce the partial encoding cheaply, so the unbounded credential-exposure claim stands.
UPHOLD-FENCED F2 website/src/pages/chat/AssistantMessage.tsx:506 -- Local variant paging is the default branch for every non-last regenerated row, so the stale-metadata condition is reached by an ordinary user action and no extreme-conditions rarity argument can be made.
[GPT-ADJUDICATED-FENCED] a8250ab09afd7a001bcc489ace09b9835486df9d

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

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 23, 2026
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

Two advisory findings; nothing blocks.

FINDING — website/src/pages/chat/AssistantMessage.tsx:506 — a locally switched variant (effectiveContent = ... variants[localIdx]?.content on every assistant row where onSwitchVariant is undefined) renders its own text while blockedLinks={blockedLinks} still carries the ROW's meta.blocked_links, so the chip's disclosure states a path and query_chars for a URL the displayed text never held → Fix: on that same branch pass variants[localIdx]?.blocked_links instead of the row's blockedLinks (the records already reach the client via _prepare_messages' {**v, ...} spread).

FINDING — website/src/components/MarkdownRenderer.tsx:2215 — { chars: queryChars } hands a raw number to a {{chars}} placeholder with no format spec, so i18next stringifies it and a six-digit count renders ungrouped in every locale, against website/AGENTS.md:74 ("Never format a date, number, or sort order without naming a locale") → Fix: { chars: fmtNumber(queryChars) }, the seam the sibling chat components already use.

[OPUS-REVIEWED] a8250ab

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

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

@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from e08e62c to 9f0d2ee Compare September 23, 2026 22:42
@buluoray

Copy link
Copy Markdown
Contributor Author

Round 1 dispositions for 9f0d2ee286c2ad12f741c199f688dfc0f11851ad (no lane emitted span ids this round, so they are grouped by lane rather than posted one per span).

GPT — F1 chat_utils.py:1756, blocked-link metadata has no count or field bounds — agreed, fixed.

The finding is right and the anchor names the reason better than the symptom: the store is the transcript line, so the bound has to sit at RETENTION and not at a render site. Three named constants now apply at both retention points — the collector in security/exfil.py and the re-validation that reads the line in chat_utils.py:

  • MAX_BLOCKED_LINKS_PER_MESSAGE = 32 caps the count in the collector, and again where the line is read, with the overflow counted in one logger.info line.
  • MAX_BLOCKED_LINK_PATH_CHARS = 256 drops an over-long path rather than truncating it. Truncation would give "only what the removers pass is kept" a weaker second branch; dropping keeps the rule single.
  • MAX_BLOCKED_LINK_QUERY_CHARS = 100_000 marks a count above it malformed rather than merely large.

One property worth stating because it is the part that must not regress: the cap bounds what is DESCRIBED, never what is removed. A message with more blocked links than the cap still has every one of them redacted out of its text; only the records stop. A test pins that (test_the_record_count_is_capped_but_the_text_is_fully_redacted), alongside tests for the dropped over-long path and for a forged line carrying four times the cap in well-formed records.

UX — "Inspect" promises examining the link — agreed, renamed.

This is the sharpest finding of the round because it is about the one thing the design deliberately does not have. The query is not kept, so a control promising a look at the link sends every reader hunting for what the panel then denies. The key is now blocked_link_why and reads "Why blocked?" in all 14 locales, and a test pins the label so the old wording cannot come back. It is a deliberate divergence from the prototype's Inspect, which belongs to a variant that keeps the URL.

UX — blocked_link_query_chars reads as raw shorthand — agreed.

Now "{{chars}}-character query removed": it states what happened to the query instead of naming a quantity and leaving the reader to infer the rest.

UX and Design — cannot evaluate, no rendered evidence — accepted, captures in flight.

Correct on both counts, and the gap is mine: the description said no render exists and none did. Design notes a harness render suffices, which is the route being taken — the five states named (full chip, Inspect open, degraded multi-record, no-record fallback, and a long retained path in flowing prose) plus the light/dark comparison against the solid remote-media chip. These land on the next push rather than this one; the security bound above was worth clearing on its own.

First Principles — product-shape change without an accepted RFC — needs a decision, routed to @buluoray.

Not disputed, and it is the same block this stack's base carries: the cited record, rfc-redaction-explain-and-reveal.md, is status: draft because it ships in #12684 rather than sitting on the base branch. Nothing inside this branch can clear it — landing the RFC separately first would put its own step 1 ahead of it, and this PR is stacked on that. Which remedy applies is a maintainer's call.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 23, 2026
@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from 9f0d2ee to 936c7b7 Compare September 23, 2026 23:01
@buluoray

Copy link
Copy Markdown
Contributor Author

Evidence for 936c7b79b4fd0c3b4e5c32e14f86c43a77114997 — the Design and UX "cannot evaluate" blockers are answered: three Storybook renders of this revision are attached to the description with captions, covering all five states each lane named plus the light/dark comparison and the chip in flowing prose.

Design's note that a harness render suffices is what made this reachable without a live gateway, and the repo already had the right vehicle. Making it paint needed a one-line fix: .storybook/vite.config.ts claimed Tailwind came from the package root via PostCSS, but this package is Tailwind v4 through @tailwindcss/vite with no postcss.config, so every story rendered as unstyled text. That is corrected, with the docstring now saying why the plugin has to be there.

Reviewing my own captures found three defects that the unit tests could not see, all fixed before attaching:

  1. The disclosure was text-accent hover:underline — this app's anchor styling — on a chip that deliberately never navigates. It is now static main text with accent on hover only, and a test asserts it carries neither text-accent at rest nor underline.
  2. The panel ran its three facts together as one sentence trailing off into an identifier. They are three lines now.
  3. The rule-to-reason map sent exfil_percent_encoding and exfil_decode_saturated to the credential sentence. That is a false accusation about this gate's most common false positive: a title in a non-Latin script percent-encodes into exactly the shape those rules match, so a reader with a perfectly ordinary wiki link was told it looked like it carried a secret. Those two rules now have their own sentence naming the escaped-character run AND naming the non-Latin-title case, and a test pins every one of the seven rule ids the redactor emits to a specific reason rather than the generic fallback.

The stories also used rule ids that do not exist in exfil.py, so the first captures depicted a state no user can reach. They use the real ids now.

@buluoray
buluoray force-pushed the feat/redaction-renderer-hard-rules branch from c280274 to f7307bf Compare September 23, 2026 23:12
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

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

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

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

Scope-Verdict: CONCERNS

TIGHTENING: New validation and retention gates on the blocked-link records that ride a message's meta.blocked_links — revalidate_blocked_link / bounded_blocked_links in src/kiro_crew/security/exfil.py, applied at both retention points (_redact_meta_for_role in chat_utils, _build_message_entry_uncached in chat_persistence) and mirrored by normalizeBlockedLinks in the renderer -- the ONE threat it refuses is a forged persisted transcript line smuggling secrets or unbounded data through the new record channel into meta and onto the chip: "A persisted transcript line is attacker-writable, so a record read back from meta is re-checked against the shape the collector emits before it reaches a client" (revalidate_blocked_link docstring), with the count bound in bounded_blocked_links ("This is the ONE way to build a list of blocked-link records from something read back off a transcript line"). The shell-visible surface is deliberately preserved: redact_exfiltration_urls becomes a thin wrapper over the new collector with the identical per-URL predicate (_exfil_url_warning, whose _rule_out hook already exists at base), and none of the deny composite's four tiers (path fence, sensitive tier, audit_bash_exfiltration over _BASH_EXFIL_PATTERNS/_BASH_EXFIL_RES, rule catalog) is modified.

ADJUDICATED: 20 candidates, 0 confirmed newly-refused
No confirmed rows were handed back for this run; a regression without a verdict is not a finding, and none is claimed.

PLATFORM COVERAGE: posix — grep over the touched governance tree, the literal placeholder-prefix text in argv, .venv/bin/python -m pytest on the exfil and meta-redaction test files, python3 -c import smoke, /tmp-targeted curl/wget; these cover the POSIX spellings of the maintainers' daily operations in the exact modules the diff edits. windows — findstr and Select-String spellings of the same placeholder-constant searches with backslash separators, and .venv\Scripts\python.exe -m pytest on the same exfil test file; these cover the other host's tokenizer for every path-bearing row, since the diff's own code makes no shell-visible path assumption. any — gh/git/curl rows including query-bearing, percent-encoded, and bracketed-IPv6 (curl -gs "http://[::1]:8080/...") URLs, probing the exfiltration tier's boundary one token off the long-query, encoding, and bracket shapes the diff's collector now describes. No assumed platform was left without a candidate. The per-leg verdicts are the deterministic fold's to report, not mine.

UNADJUDICATED: The tightening itself sits in guards no shell command line reaches, so the classifier settles none of it:

  • Guard: revalidate_blocked_link / bounded_blocked_links (src/kiro_crew/security/exfil.py). Call path: a persisted transcript line's meta.blocked_links → _redact_meta_for_role on the emit path (_prepare_messages) and the save path, and → _build_message_entry_uncached on the load path, both funneling through bounded_blocked_links. Candidate legitimate inputs I could not get a verdict for: (1) a record whose retained path passed at collection only under an https/no-port exemption — the read-back deliberately re-checks as plain http with no port, so that record's path vanishes on reload (the hunk names this fail-closed degradation itself); (2) a record for a legitimate single-label internal host (localhost, intranet) — _BLOCKED_LINK_DOMAIN_RE requires a dotted name with an alphabetic TLD, so such a record is dropped while its placeholder stays in the text; (3) a legitimate host whose label happens to match a credential shape — dropped by design, chip degrades to nothing for that placeholder; (4) a carried record on a row whose placeholder text was edited or truncated — the EXFILTRATION_REDACTION_TAG_PREFIX not in content gate in chat_persistence removes the records.
  • Guard: normalizeBlockedLinks + rehypeBlockedLinkChips (website/src/components/MarkdownRenderer.tsx). Call path: ChatPage passes meta.blocked_links → AssistantMessage → MarkdownRenderer prop → normalizeBlockedLinks → domain-set-gated rehype pass. Candidate legitimate inputs: a record the backend retains but the frontend regex rejects (the two host regexes currently agree — dotted names with underscores, dotted-quad, bracketed IPv6 — and the frontend rule regex is strictly looser, so no divergence is arguable today, but nothing adjudicates that parity); a placeholder inside an anchor, code, or pre, which deliberately stays plain text; a pre-existing transcript with placeholders and no records, which renders exactly as at base.

None of these guards can be expressed as a shell row, so no verdict exists for them; CONCERNS is the honest verdict, and a PASS built on the empty adjudicated set would be the false green this lane exists to prevent.

[SCOPE-REVIEWED] a8250ab

@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch 2 times, most recently from e129326 to eceac82 Compare September 23, 2026 23:39
@buluoray

Copy link
Copy Markdown
Contributor Author

GPT F1 security/exfil.py:1128 — agreed, fixed at eceac821ea74574d410ec26b8317f9c824a7ebf1. All three conditions were real: the domain and rule patterns used + with no length bound, and seen.add(matched) ran before the cap test so a dedupe row existed for a match the cap had already refused.

This is the SECOND time this rule has fired on this diff by a different escape route — last round the count was unbounded, this round the strings and the dedupe set were — so the fix is not a third set of per-field checks. Being bounded is now a property of the record's shape: _BLOCKED_LINK_STRING_BOUNDS maps every string a record may retain to its limit, and the validator iterates that table instead of naming fields, so a field added later without an entry is not retained at all. A test pins the table against the record's own key set, which is what makes that hold for a field nobody has written yet.

The rest follows from it: the domain and rule patterns now carry bounded quantifiers (253 is the DNS maximum, so a longer host is not a host this collector saw), the length check runs before any regex, the collector falls back to exfil_unknown rather than retaining an over-long rule id, and seen.add moved below the cap guard so the dedupe set cannot outgrow the cap either.

One property the tests keep separate, because conflating them would be the dangerous reading: the cap bounds what is DESCRIBED, never what is REMOVED. A message carrying more blocked URLs than the cap still has every one of them redacted out of its text — test_the_dedupe_set_stops_growing_at_the_cap sends each URL twice and asserts none of them survives in the output while the record list stops at the cap.

@buluoray
buluoray force-pushed the feat/redaction-renderer-hard-rules branch from f7307bf to 48c4fb7 Compare September 23, 2026 23:56
@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from eceac82 to 77ac82c Compare September 24, 2026 00:02
@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 Sep 24, 2026
@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from 77ac82c to 74ae26e Compare September 24, 2026 00:21
@buluoray

Copy link
Copy Markdown
Contributor Author

GPT F1 chat_persistence.py:2927 — agreed, and it was worse than a gap: the feature never fired on a live turn. Fixed at 74ae26ed3d11f17fb88dcd8455a484b39dddade5.

_flush_segment redacts the assistant text and appends the RESULT, so the row holds the placeholder from the moment it exists. Persistence then scanned that placeholder, found nothing, and attached no records — so no chip, ever, for the message that produced the link. My own persistence test passed because it fed unredacted content straight to _build_message_entry_uncached: it proved the attach point works in isolation while validating a state the product never produces.

The fix is where the finding points, and it is also the honest shape: records are born at the ONE moment the URL still exists — the redaction inside _flush_segment — and carried from there. They ride in the meta slot.append already takes, which that call's own comment explains is the way to reach BOTH doors: the row it stores and the live frame it broadcasts. So the chip now appears on the turn that produced it rather than after a refetch.

Everything downstream became a subtraction. Persistence no longer derives records at all (it cannot; it only ever sees the placeholder) and simply carries what the row arrived with, so the second collector is gone. The memoised front door's _carry_blocked_links_to_row helper and its four call sites are deleted — the row is the source now, so there is nothing to copy onto it, and the cache-hit hole it existed to close cannot exist either.

Tests follow the same correction. The persistence cases now feed the shape the live path produces (content already a placeholder, records in meta), one asserts persistence does NOT invent records from a placeholder, and a source guard pins _flush_segment to the records variant — because the wiring is the defect and no unit on the persistence layer can see it. 1332 backend tests pass.

@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 Sep 24, 2026
@buluoray
buluoray force-pushed the feat/redaction-renderer-hard-rules branch from 48c4fb7 to fa04137 Compare September 24, 2026 00:39
@buluoray

Copy link
Copy Markdown
Contributor Author

First Principles item 7 for 3fe2fee7e007ff40098b99f59954a14b3d64b6d0 — agreed, and it is residue from my own retrospective one revision ago.

Routing both retention points through bounded_blocked_links made revalidate_blocked_link an implementation detail of exfil.py, and I left behind the surface it no longer needs: a public export plus a dead import in chat_persistence.py. Both are gone. The function keeps its direct tests, which now import it from kiro_crew.security.exfil — a per-record validator is worth testing in isolation, but tests are not a reason to keep a symbol on the public surface.

That is the whole of item 7. The remaining First Principles block on both this PR and its base is the RFC-on-base class, which is a maintainer decision rather than something I can close from here.

@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from e792ac3 to 3fe2fee Compare September 24, 2026 02:46
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

GPT round dispositions for f15631d9ad761d088d88ec60a36dc98f11fa0732.

BLOCKING, a credential-shaped host walks past the text redaction — agreed, and it is an inconsistency in my OWN stated rule rather than a new idea. The RFC says a retained string is kept only when the removers themselves would pass it, and I applied that to path while leaving domain checked by a shape regex alone. A DNS label can be shaped like a credential, so a record could carry that secret into meta and onto the chip after the text redaction had done its job.

_blocked_link_safe_domain now answers both the host regex and redact_credentials(domain) == domain, and BOTH the collection point and the read-back re-check ask it — so a host cannot be validated in one place and trusted in the other, which is the shape of every recurrence this review has found in the retention code.

A second invention, found while fixing the first and not reported by any lane: the collector fell back to rule = "exfil_unknown" when the tracer gave no id or an over-long one. That is the backend minting the same fabricated id the UX lane caught in the frontend's degraded panel — I fixed the render side last round and left the source of it in place. There is now no sentinel at all: no usable rule id means no record, and a test asserts the string appears nowhere in the collector. The URL is still redacted from the text either way, which is the line that must never depend on any of this: a dropped record costs the reader an explanation, never the removal.

FINDING, bracketed IPv6 — agreed, and it was real in both regexes. A backend test pins what the placeholder actually carries ([2001:db8::1], brackets included); the host pattern now admits a bracketed literal, and the placeholder capture takes the bracketed form FIRST, because [^\]]+ stopped inside [::1] and left the reader a mangled placeholder with a stray bracket rather than a chip.

Gates: 1251 backend, 1422 frontend, black/isort/flake8/mypy/comment-history/tsc/eslint clean.

@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from 3fe2fee to f15631d Compare September 24, 2026 03:07
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

First Principles item 6 for 7119fa3c7dae105979c8ea2f4d163c1ea45a0556 — agreed, and taken wider than reported.

Once bounded_blocked_links absorbed the cap, nothing outside exfil.py needs the constant, and _exports.py freezes a name until it is deleted — so an unused entry there is a public commitment to nothing. The reported MAX_BLOCKED_LINKS_PER_MESSAGE is gone from the facade.

So are its two siblings, MAX_BLOCKED_LINK_PATH_CHARS and MAX_BLOCKED_LINK_QUERY_CHARS, which have exactly the same zero-consumer story. Fixing only the named one would have left the identical defect standing twice, and "the sibling did not get the same treatment" is the miss this review has caught in my work more than once — the media caption's guard, the two encoding rules, the domain-vs-path removal rule. All three constants keep living in exfil.py; the tests that assert against them already reach them as exfil.<NAME>, which is the right address for a bound that is now an internal property of the record shape.

bounded_blocked_links stays on the facade because it has four real consumers in the dashboard — it is the one name outside code that needs to say it.

Gates: 1251 backend on the touched set plus 526 export/facade tests, flake8/isort/mypy clean.

@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from f15631d to 7119fa3 Compare September 24, 2026 03:22
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

Opus host-shape finding for ff15fc30b301c014852a2fdfb23ca4060a27d60d — agreed, and it caught the half of my own previous fix that I left undone.

Last revision I widened the render-side host pattern for bracketed IPv6 and stopped there. The backend's gate admits THREE shapes, and the third is a dotted name carrying _ ([a-zA-Z0-9._-]), which internal and SRV names really do. So a host the backend both emits and re-validates was still being dropped render-side — and the cost of dropping is specific: the placeholder stays in the text with nothing explaining it, which is the failure this whole PR exists to remove, landing on hosts least likely to be typed by hand.

Rather than widen the pattern a second time, the render side now MIRRORS the backend's regex shape for shape, in its order, with a comment saying that is what it is. The render side should not hold its own opinion about what a valid host looks like: that opinion drifting from the backend's is exactly how this appeared twice.

Pinned from both ends so the next drift fails a test rather than a reader: a frontend case asserts a chip for my_service.example.com, 203.0.113.7 and [2001:db8::1], and a backend case asserts revalidate_blocked_link keeps the underscored host, so the two gates cannot quietly diverge.

The bracket-aware placeholder capture from the previous revision stands, since a bracketed host makes a [^\]]+ capture stop at the inner ].

Gates: 1241 backend, 1423 frontend, black/flake8/comment-history/tsc/eslint clean.

@buluoray
buluoray force-pushed the feat/redaction-blocked-link-chip branch from 7119fa3 to ff15fc3 Compare September 24, 2026 03:43
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

GPT round dispositions for f92cc216f6320c63190b4b97cd9914a352af9d62 — both agreed, both mine, and together they name the root cause the earlier retrospective stopped short of.

seen.add(matched) before the rejections — agreed. An earlier round moved that line BELOW the cap guard for exactly this reason, and I then inserted the domain and rule rejections BELOW it, re-opening what that fix closed. seen holds whole URLs and is bounded only by the record cap beside it, so a unique-but-rejected URL grew it with nothing bounding the growth. Every rejection now happens before it grows.

A domain the collector kept and the reload dropped — agreed, and this is the worse of the two: the record displayed once and then vanished under the reader after a reload, which is a stranger failure than never appearing. The collector's host check was the regex plus credential-safety; the read-back's was those plus the 253-char bound from the table.

The root cause behind both, and behind the last three rounds on this anchor: the collection point and the read-back validated the SAME record shape through two separate code paths, so every round found one more check present on one side and absent on the other — the count bound, then the credential rule, now the length bound and the ordering. My previous retrospective unified how a record LIST is built (bounded_blocked_links) and left the FIELD checks duplicated, which is why the class kept producing new instances.

_blocked_link_fields_ok(domain, rule, query_chars) is now the single posture-independent field gate, asked by the collector before seen grows and by revalidate_blocked_link on read-back. Only the retained PATH still differs between them, because its check genuinely depends on the posture the URL arrived under — that one field's asymmetry was never a reason for two validators, which is the mistake I made when I kept them apart.

A test states the property directly rather than testing the two paths separately: anything collection keeps, the read-back keeps (bounded_blocked_links(records) == records). Plus one that floods the collector with unique rejected URLs and asserts the dedupe set gains nothing, and one that asserts every collected record survives its own re-validation.

Gates: 1255 backend, black/isort/flake8/mypy/comment-history clean.

…eholder

When the exfiltration check blocks a URL the reader is left with plain text
naming only the site: `[REDACTED: suspicious URL to example.com]`. It cannot be
selected, it does not say why the link was blocked, and it gives the owner no
way to judge a false positive. The rest of the URL is discarded before the
message is written, so nothing a renderer can reach explains the block.

This retains STRUCTURE and never the query value, and the rule for what may be
kept is that only what the removers themselves would pass is kept. A path is
kept only when the path ALONE fails to trip the URL warning and survives
credential redaction unchanged, because a link can smuggle data in its path as
readily as in its query. The query is described by its length and never stored.
Keeping this does not feed the link back to the model: the replay is built from
role and message text only and that text is re-run through both removers before
injection, so a detail in a message's meta is never part of it.

What one message may retain is BOUNDED at both retention points rather than at
a render site, because the store is the transcript line: a record is cheap to
write there and every render re-validates and re-serializes whatever the line
holds. `MAX_BLOCKED_LINKS_PER_MESSAGE` caps the count in the collector and
again where the line is read, with the overflow counted in one log line; a path
over `MAX_BLOCKED_LINK_PATH_CHARS` is dropped rather than truncated, which keeps
"only what the removers pass is kept" from acquiring a weaker second branch; a
count over `MAX_BLOCKED_LINK_QUERY_CHARS` marks the record malformed. The cap
bounds what is DESCRIBED and never what is removed -- every blocked URL is still
redacted from the text.

The records and the redaction come out of ONE loop.
`redact_exfiltration_urls_with_records` holds the body and
`redact_exfiltration_urls` becomes a thin wrapper, so no existing caller
changes and two scans cannot disagree about which URL was blocked. Records
carry no positional index on purpose: the placeholder names only the domain, so
two different URLs on one host produce byte-identical placeholders and an index
could attach one link's path to another. The chip pairs by domain and shows the
host and reason alone when a host has several differing records.

A transcript line is attacker-writable, so `revalidate_blocked_link` re-checks
every record read back from meta -- exact key set, strict host, `[a-z0-9_]`
rule id, bounded count, and a path that still passes both removers under the
strictest posture available. A record that fails is dropped on its own and its
siblings stand.

Two readers need the records and both get them from that one scan. The saved
entry carries them; the memoised front door copies them onto the live row,
because the display path hands the ROW's meta to the redactor and a cache hit
never runs the body. A rehydrated row holds the placeholder rather than the URL
so a rescan finds nothing -- content survives a reopen because redaction is
idempotent, records are derived, so they are carried forward while the content
still shows a placeholder.

The chip is injected by a rehype pass that runs after `rehypeSanitize`, so
`blocked-link` stays out of the agent-influenceable tag allowlist and a literal
tag written in prose is still escaped. It is never an anchor and never
navigates. The disclosure is labelled for the outcome it delivers -- "Why
blocked?" rather than "Inspect", because the one thing a reader wants is the
query and that is the thing deliberately not kept, so a label promising a look
at the link sends them hunting for what the panel then denies. The panel states
in plain language why the rule fired and that the query was not kept, and the
char count reads as what happened to it rather than as shorthand.

Design record: docs/request-for-change/rfc-redaction-explain-and-reveal.md,
section 3 and the retention tradeoff recorded under it. Stacked on the renderer
hard rules it builds against.

Copy URL and Open once are deliberately absent: they need the query value, and
keeping that puts sending it one confirmation away.
@buluoray

Copy link
Copy Markdown
Contributor Author

Scope-lane candidate refusal for a8250ab09afd7a001bcc489ace09b9835486df9d — the lane is right to refuse, and the fix is mine to make rather than an override to ask for.

Security scope candidate validation failed on its own corpus, not on this diff: a proposed candidate operation carried a credential shape in a field the classifier reads, and since the candidate set travels as a public artifact and must stay byte-faithful, it can be neither published nor rewritten. The source was my own test fixture — the credential-shaped HOST I added to prove the domain gate was spelled as an access-key id, so the reviewer sampling this diff's vocabulary built a candidate URL around it.

The test needs a host the credential remover rewrites; it never needed a cloud key. The fixture is now a token-prefix shape held in one named constant with a comment saying why it is not an access-key id, an ARN or an account id. All three cases still assert exactly what they did — collection refuses such a host, read-back drops a forged one, and the URL is redacted from the text regardless — and the scope lane's corpus stops carrying a shape it cannot attribute.

I did not reach for /ai-review override scope, which the job offers: the refusal is describing a real property of what I wrote, and an override would have left the next reviewer's corpus carrying it.

Gates: 1244 backend, black/flake8/comment-history clean.

@buluoray

Copy link
Copy Markdown
Contributor Author

Folded into #12684, which now carries rollout steps 1 and 3 together, stacked on the RFC in #13250. Every commit and screenshot from this PR is in #12684's single commit and body.

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.

1 participant