Skip to content

feat(security): name the rule that redacted a URL after its placeholder - #14783

Open
Pearcekieser wants to merge 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/exfil-redaction-rule-id
Open

Pearcekieser wants to merge 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/exfil-redaction-rule-id

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A blocked link's placeholder is followed by which kind of rule removed it, so a reader can tell a likely secret from a false positive.

A blocked link is replaced with [REDACTED: suspicious URL to <host>]. The redactor blocks for two different reasons: the link held something shaped like a credential, or it only tripped a shape heuristic (a 200+ character query, a base64-like run). The placeholder does not say which, so the reader cannot choose between stripping the query and reporting a false positive.

Why it matters

The dashboard's Blocked link chip explains the reason only when its record survives. Slack, iMessage and the other channels, the model's own context, and any message whose record was dropped see the placeholder text and nothing else. Every false positive there looks exactly like a leaked secret.

Not a goal

  • Changing which URLs are blocked. The heuristics, their order and every exemption are untouched.
  • Adding a reason to the browser-side mirror in website/src/utils/sanitize.ts. It has no rule ids and redacts only on client-only render paths.
  • Changing the Blocked link chip, which already explains the reason from the record.

What changed (motivation → approach → change)

A blocked link's placeholder is now followed by the reason it was blocked, so a reader can tell a likely secret from a heuristic false positive.

Rule id Reason after the tag
exfil_hard_credential, exfil_fixed_credential credential
exfil_encoded_credential encoded credential
exfil_percent_encoding, exfil_decode_saturated heavy encoding, may be legitimate
exfil_query_length long query, may be legitimate
exfil_query_pattern random-looking query, may be legitimate

A blocked link now reads [REDACTED: suspicious URL to learn.example.com] (long query, may be legitimate). _exfil_url_warning already reported a stable rule id that it never builds from URL text. exfiltration_redaction_tag() looks that id up in the fixed EXFIL_RULE_LABELS table and writes the words after the tag. A rule missing from the table gets no reason, which is the old text.

The tag itself keeps main's exact shape, so no pattern changes. _PLACEHOLDER_RE in exfil.py, _REDACTION_TAG in messaging/display_safety.py, _LINK_PLACEHOLDER_RE in dashboard/chat_turn/segment_flush.py and BLOCKED_LINK_PLACEHOLDER_RE in RedactionCards.tsx are all main's. Two readers need the reason, and both compare the whole suffix against the fixed EXFIL_RULE_REASON_SUFFIXES:

  • restore_allowed_links puts an allowed link back in place of its tag. With startswith, it also removes the (<reason>) of the record it restores, and leaves any other text.
  • The chat segment save compares the streamed copy with the whole-text copy, and a stream delta cut can trip a different rule than the whole URL. _without_reasons replaces each exact ] (<reason>) with ] in both copies, before the run-by-run check (_blank_tags, then main's pattern) and before the count of each value a delta removed (_kept_removed_values).

The prefix constant, the table and the builder live in security/exfil_url_rules.py, because exfil.py is at the 2,000-line cap. exfil re-exports them, so every caller keeps its import. The categories are documented in docs/system-specs/modules/security.md, and stories/Redaction.stories.tsx renders every reason. test/test_security_gate_liveness.py re-pins the security package line budget for the 37 lines this adds, with the reason next to the number.

Security argument: the reason is a lookup keyed by a rule id from a closed set, so it cannot carry attacker-chosen bytes; two URLs on one host that trip the same rule redact to identical text. No check, threshold, order, exemption or pattern changed, so nothing that was blocked passes. The restore path still restores only records whose rule is exfil_query_length or exfil_query_pattern.

Backwards compatibility

Compatible: the prefix constant, the tag shape and every rule are unchanged, and text saved before this change has no reason after its tags. Redacted text grows by up to 42 characters for each blocked link, so a length-capped field that is measured after masking, such as an autonudge banner near its 500-character cap, can now be refused where main accepted it. On the last-resort delivery path that removes every whitespace run outside tags (messaging/split._flattened_for_any_cut), the reason loses its spaces and reads (longquery,maybelegitimate); the tag and its count are kept.

Tests

  • test/test_exfil_rule_labels.py: one real URL per rule id produces its reason after the tag, the tag keeps main's shape and the suffix is one of the fixed set, the prefix stays intact, two different URLs tripping the same rule give identical text, an unknown rule adds no reason, every trace() id in exfil.py has a table entry, and redaction stays a fixed point.
  • The same file covers restore: an allowed host restores a link and drops its reason, other text after the tag stays, a credential link is never restored, and words written inside the brackets are not a reason. A segment cut across stream deltas keeps its record when the streamed and whole copies trip different rules, for an ordinary host and [fd00::1]. A delta that removed the one letter h does not withhold a reply whose whole-text reason has more h than the streamed one. The five shipped suffixes stay in EXFIL_RULE_REASON_SUFFIXES.
  • MarkdownRenderer.blockedLink.test.tsx: a tag followed by a reason still pairs with its record and the reason shows after the chip, one with no record stays as text, and words inside the tag never pair.
  • Tests in 18 existing files asserted the exact placeholder text and now include the reason after it. Four display tests in test_markdown_link_parentheses*.py take the tag from the redactor's output with the exact suffix removed.
  • test_slack_handler_composition_contract_golden.py: three digests change. With an empty reason table they match main, so the reason is the only change.
  • test_autonudge_banner.py: the at-cap banner negative control uses a longer URL, because the reasoned text is longer than its old 65-character fixture; it still proves a banner that redaction shrinks is accepted.

Manual verification

N/A. Unit coverage exercises the redactor end to end on real URLs and the renderer on real markdown.

Screenshots / video

Each reason as a reader sees it when the tag has no record (a channel message, or a dashboard reply whose record was dropped), plus one tag with its record rendering as the unchanged Blocked link chip with the reason after it. Captured from the Chat/Redaction/PlaceholderReasons story.

Reasons after the tag with no record, dark theme

Light theme

Reasons after the tag with no record, light theme

Related Issues

The closing reference is the last line of this description.

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

Fixes #14782

@Pearcekieser
Pearcekieser requested a review from a team September 28, 2026 18:01
@Pearcekieser
Pearcekieser requested a review from a team as a code owner September 28, 2026 18:01
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: A blocked link's placeholder names the kind of rule that removed it, using fixed words keyed by rule id, so a reader can tell a likely secret from a heuristic false positive.
Not a goal: Changing which URLs are blocked, adding a reason to the browser-side mirror in sanitize.ts, or changing the Blocked link chip.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 564bf30d76d2ac05c261d59d5a11d75d90a5e9e5 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the reason is looked up from a fixed table keyed by rule id, the tag keeps main's shape, and every in-tree reader matches the tag by prefix or by substring.

Notes

  • The reason words get saved into transcripts, so they can't be changed later. The append-only pin (test_the_reason_suffixes_are_append_only) is the only thing keeping old stored text matchable, so keep it as a hard gate and not something to tidy away.
  • In the dashboard, the reason now shows as plain text after a Blocked link chip whose card already explains it. Later, consider dropping the suffix on the render side when the tag has a record.

[DESIGN-REVIEWED] 564bf30

Description read

[DESCRIPTION-READ] 0756f8791436bb05a578dca03d4ec9ad169264b0fa2997fdd988337e9e7028d1

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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 564bf30d76d2ac05c261d59d5a11d75d90a5e9e5 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. Both attachments show all five reasons and the chip followed by its reason, in dark and light themes. This fork lane has no blind read, so nobody new to the product has read these strings yet; pushing the branch to this repo gets one.

Notes

  • After the Blocked link chip, the trailing "(long query, may be legitimate)" repeats a reason that the chip's Inspect view already explains. Hide the suffix when the tag is paired with its record, so the reason appears once.
  • "(credential)" doesn't tell the reader what to do next, while the heuristic reasons signal "may be legitimate". "(looks like a credential)" says it is a likely secret in the same tone.

[UX-REVIEWED] 564bf30

Description read

[DESCRIPTION-READ] 832819f60a3e4fb6ff5f89c3aa67b474e88c3af4435fac460803b8e10c3f10dc

That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 564bf30d76d2ac05c261d59d5a11d75d90a5e9e5 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 564bf30

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 564bf30d76d2ac05c261d59d5a11d75d90a5e9e5 via the fork AI-review pipeline — 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. The fix targets the cause (the placeholder named only the host) and is tied to #14782. Two notes concern the reason wording now living in two tables.

Notes

  • Item 3 — duplicate of linkReason in website/src/components/RedactionCards.tsx:1336: the dashboard now shows the backend's untranslated English reason right after a chip whose card already gives the reason. The two tables already disagree: linkReason files exfil_encoded_credential under credential, while EXFIL_RULE_LABELS gives it its own "encoded credential". Subtraction: fold exfil_encoded_credential into "credential" in EXFIL_RULE_LABELS. That drops one label and one entry from EXFIL_RULE_REASON_SUFFIXES, and the two tables then classify alike.
  • Item 1 — product shape, coverage needs an argument: rfc-redaction-explain-and-reveal.md (partial) line 508 says "Keep the existing placeholder tag and store that value's rule and source in its metadata". This PR instead changes the placeholder text that every channel and the model's context receive. Deciding whether the RFC covers that is a judgement call, so this is a note and not trigger (c).

What this change ships

Inventory (8 items) — 6 justified

Intent: let a reader of a blocked-link placeholder on any surface tell a likely secret from a heuristic false positive. ADDITION.

  1. Every blocked-link placeholder, on every surface, now ends with a fixed reason in parentheses — justified
  2. Channel members now see credential when the reply held a credential-shaped value — justified
  3. Dashboard shows reason text after the chip, beside the card's own reason — duplicate of RedactionCards.tsx linkReason
  4. Allowing a host restores the link and removes its reason — justified
  5. Streamed-vs-whole segment comparison ignores reason words — justified
  6. Placeholder prefix moves to exfil_url_rules.py, re-exported — justified
  7. Security package line budget rises by 37 — justified
  8. Redacted text grows by up to 42 chars, so a length-capped field near its cap can now be refused — undeclared in the Goal, declared under Backwards compatibility

[FIRST-PRINCIPLES-REVIEWED] 564bf30

Description read

[DESCRIPTION-READ] bf86df93ced2c18c6c27a8f742a40ec3612493880c1262014dd0f8b8d6b1eecd

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 Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 564bf30d76d2ac05c261d59d5a11d75d90a5e9e5 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 564bf30

@Pearcekieser
Pearcekieser force-pushed the feat/exfil-redaction-rule-id branch from d9be12f to f11b2c2 Compare September 28, 2026 19:14
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): "heavy encoding" sorts to the wrong side of the secret/false-positive line

fixed: the spec sentence was the error, not the word. Heavy percent-encoding is a shape check that legitimate links trip (a non-Latin title percent-encodes into a 20+ octet run), which is why the dashboard card already says so. The spec now groups heavy encoding with the two query checks as shape checks and keeps only credential / encoded credential as the credential-shaped rules.
The word stays heavy encoding, because it names what the reader can check in the link.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

question (non-blocking): no cold reader has read the five reasons

rebutted as a lane limitation, not a defect: the five words are short observations of the link ("credential", "encoded credential", "heavy encoding", "long query", "random-looking query"), and the least clear one is renamed in this head. A human reviewer reading them before merge is the right check; @Pearcekieser has been asked to read them.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): replace "data-like query"

fixed: exfil_query_pattern now reads random-looking query, which names what the reader sees (a long base64-like run) rather than the heuristic. Changed in EXFIL_RULE_LABELS, the dashboard LINK_REASON matcher, the spec and the tests.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

fixed in f11b2c2: the security package line budget in test_security_gate_liveness.py is re-pinned with its reason (Backend Tests shard 2 on Linux and Windows), and the dashboard reason matcher is built from regex-literal sources so the i18n strict gate no longer reads it as copy (Frontend Lint & Type Check). The UX lane items are answered above.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — ✅ PASS

Which legitimate operations does 564bf30d76d2ac05c261d59d5a11d75d90a5e9e5 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

adjudicated, zero confirmed regressions

Scope-Verdict: PASS

Reason: The diff changes the text written after a blocked link and how two readers handle that text. It doesn't touch any of the three shell deny tiers: exfil_bash.py, the _exfil_url_warning patterns and denied_rules.py are all unchanged, so it can't newly refuse a shell command. The one strictness change is a display-side text comparison in the segment-save check. The classifier can't judge it, so it is named under UNADJUDICATED.

TIGHTENING: segment-save leak check (segment_flush._kept_removed_values), now compared over reason-stripped text -- it refuses a removed credential value coming back in the saved copy, now also when the value contains a blocked-link tag with its reason: if bare_saved.count(_without_reasons(v)) > bare_delta.count(_without_reasons(v)) and not _only_inside(saved, v, links). The rest of the diff only rewrites output (placeholder = exfiltration_redaction_tag(domain, next(iter(rules), None))) and refuses nothing.

ADJUDICATED: 14 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix and windows. The diff adds no assumptions about paths, separators, interpreters or environment variables in the deny path. Its only new assumption is a fixed ASCII suffix ] (<reason>), which is the same on every host. Even so, each probed operation has its own posix row (forward slashes, curl, npx, kirocrew) and windows row (backslash paths, findstr, curl.exe, npx.cmd, kirocrew.exe). They cover test runs in the touched area, placeholder and source searches, a short-query URL fetch that the exfil tier sees, and the Slack manifest link emitter that the redactor exempts. No assumed platform was left without a row.

UNADJUDICATED: Guard: the chat segment-save consistency check in src/kiro_crew/dashboard/chat_turn/segment_flush.py. Call path: each streamed delta goes through chat_runner._redact_delta, then _accumulate_segment_raw collects the removed values. At flush, _redact_segment calls _kept_removed_values(saved, per_delta, removed, links), which now strips every EXFIL_RULE_REASON_SUFFIXES entry from both copies and from each value before counting. If a value is judged kept, the segment is saved as _SEGMENT_UNCHECKED_TEXT instead of the reply. _blank_tags also strips reasons now. These are inputs I would have submitted but no shell row can express:

  • an assistant reply that itself quotes a fixed reason phrase right after a ] (for example a markdown footnote [1] (credential), or prose like see [docs] (long query, may be legitimate)). Stripping turns these into ], so the counts can change and an ordinary reply could be saved as the unchecked-text placeholder.
  • a reply that quotes an earlier blocked-link placeholder with its reason, alongside a link that a delta cut blocked under a different rule.

The suffix match is exact and whole ("]" + reason), so I could not show such a reply being refused through the call path. This is named, not blocking.

[SCOPE-REVIEWED] 564bf30

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (blocking): the reason words name the detector, not the verdict

fixed: the three shape-check reasons now say so themselves: heavy encoding, may be legitimate, long query, may be legitimate, random-looking query, may be legitimate. The two credential reasons (credential, encoded credential) carry no such tail, so the secret/false-positive split reads from the words alone rather than from security.md. Changed in EXFIL_RULE_LABELS, the LINK_REASON matcher, the spec, the story and the tests; the test that pins the two word lists equal still passes.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): no image of the reasoned placeholder rendered where a record is absent

fixed: the description now carries screenshots (dark, light) of all five reasons rendered by MarkdownRenderer with no record, next to one placeholder whose record renders as the unchanged chip. They come from the new Chat/Redaction/PlaceholderReasons story, so the frame is reproducible from the branch.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): no blind reader has read the new strings

rebutted as a lane limitation, not a defect: the lane confirms every changed string and state is in the attached captures. A human read of the five reasons before merge is the remaining check, and it is with the PR author.

@Pearcekieser
Pearcekieser force-pushed the feat/exfil-redaction-rule-id branch from 5d9fee1 to 4264b8b Compare September 28, 2026 22:29
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): restore the Detects bullet

fixed in 4264b8b: restored to "Detects: long query strings (≥200 chars)"; every other added line carrying the new words was checked and is intended placeholder text.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): the Detects bullet rides along

fixed in 4264b8b: the stray edit is reverted, so the spec hunk now touches only the redact_exfiltration_urls bullet.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): _PLACEHOLDER_RE cannot capture a bracketed IPv6 host

fixed in 4264b8b: the host capture now tries a bracketed literal first, (\[[^\]]+\]|[^\]\s]+), the same shape as the dashboard matcher. test_a_bracketed_ipv6_host_is_restored redacts and restores an allowed [fd00::1] link. The line budget moved by one for it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): the spec's Detects sentence was corrupted by the find-replace

fixed in 4264b8b: the bullet reads "Detects: long query strings (≥200 chars)" again. The reasons are documented only in the redact_exfiltration_urls bullet.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): the label words are now part of the persisted message format

fixed in 4264b8b: the words are append-only. security.md states that both matchers must keep accepting every wording ever shipped, and test_the_dashboard_matcher_accepts_every_reason now checks that the frontend list is a superset of EXFIL_RULE_LABELS rather than equal to it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): stray replacement in the spec's scan bullet

fixed in 4264b8b: restored to "Detects: long query strings (≥200 chars)".

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): raw-copy adoption in _redact_segment now requires the rule to agree

fixed in 4264b8b: a URL split across stream deltas can trip another rule than the whole URL, so the reasons can differ between text and raw. The pairing now matches the placeholder by host alone (the prefix plus the domain, followed by ] or (), which is what it matched before this PR. test_a_segment_pairs_the_raw_record_when_the_reasons_differ covers the case.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): build _REASONS from a shipped-wordings set rather than EXFIL_RULE_LABELS.values()

rebutted as disproportional here: no wording has shipped yet, so labels and shipped wordings are the same set, and a second table would only duplicate the first. The failure the lane describes is fail-safe (an old placeholder stays text with its record; no link is restored), and the spec's append-only rule already says a rewording keeps the old words in both matchers. The first rewording is where the retired-words set belongs.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main (e86fbdc) with no behaviour change, to pick up #29942. That PR removed the three strict scale-F4 markers that failed Backend Tests (3.12, 4) on f04ce29. The rebase had no conflicts and git range-diff shows both commits unchanged. Locally, 451 test files ran, including test/scale_budget/test_catalog_budget.py and the shard 5 test that failed once: 26,130 passed. The 25 failures are all test_cloud_source_staging.py and cloud/source.py refusing a / owned by another uid in this sandbox.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main (068a1f5) with no behaviour change. The only conflict was _PACKAGE_LINE_BUDGET in test/test_security_gate_liveness.py: #29289 added one TickTick consent host to exfil_oauth and raised the pin to 34,523. The resolution keeps main's paragraph and pins the measured total, 34,550, which is the same 27 lines above main's pin as before. git range-diff shows the second commit unchanged. Locally, 158 test files ran with 10,542 passed. The 54 failures are all test_enterprise_policy_fetch.py and test_kas_bundle.py, which fail on the Kiro sign-in and the KAS engine that this sandbox lacks. None of them is in redaction code.

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

Requesting changes at b9561ae for one reason: naming the rule in the placeholder is done by widening regexes that parse redacted text, and our review rule does not accept a solution that adds or widens regex parsing.

The widened patterns are:

  • the placeholder pattern in messaging/display_safety.py gains an optional (<reason>) group built from _REDACTION_TAG_REASONS
  • _PLACEHOLDER_RE in security/exfil.py now also accepts a bracketed host and the same optional reason suffix, via the new EXFIL_RULE_REASONS_RE

Each new reason word is now one more alternation that every downstream reader has to match exactly. A placeholder that drifts from the pattern stops being recognised as a placeholder, which in this code path is a redaction miss.

A structured approach would avoid that, for example:

  • carry the rule as a typed field next to the redacted span, the way the redaction cards already get their data, instead of encoding it into the placeholder text and parsing it back out, or
  • if it must live in the text, split the known suffix with an exact token check (endswith(" (" + reason + ")") against the fixed reason set) rather than extending the regex.

The security direction itself is neutral: it labels a redaction and refuses nothing new, so that part is fine. CI is still running on this head, and GPT, Opus and Sensitive Change Review are red. Please look at those lanes too when you push.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

@bolichen97 Thanks. I will take your second option and remove every regex change in this PR.

The reason moves outside the tag: [REDACTED: suspicious URL to <host>] (<reason>). The tag itself keeps main's exact shape, so every existing pattern matches it unchanged, and I revert _PLACEHOLDER_RE, display_safety._REDACTION_TAG, segment_flush._LINK_PLACEHOLDER_RE and LINK_PLACEHOLDER in RedactionCards.tsx to main. Only two readers need to know the suffix, and both use an exact token check against the fixed reason set:

  • restore_allowed_links puts a URL back in place of its tag. It also removes a (<reason>) that follows that tag, using startswith on each fixed suffix.
  • The segment save compares the streamed copy with the whole-text copy, and a delta cut can change which rule fires. _blank_tags replaces each exact ] (<reason>) with ] before main's unchanged pattern runs.

The second commit (display_safety) goes away, because the tag no longer changes shape. The pre-redesign lane results above (GPT, Opus, Internal Content Scan, Security Scope) all say "could not run" on b9561ae, so the next push re-runs them.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

@bolichen97 Pushed the redesign as one commit, 67da36d.

  • The reason now follows the tag: [REDACTED: suspicious URL to <host>] (<reason>). This PR no longer changes any pattern. exfil._PLACEHOLDER_RE, display_safety._REDACTION_TAG, segment_flush._LINK_PLACEHOLDER_RE and BLOCKED_LINK_PLACEHOLDER_RE in RedactionCards.tsx are main's.
  • restore_allowed_links removes the restored record's own (<reason>) with startswith against that exact string. segment_flush._blank_tags replaces each exact ] (<reason>) from EXFIL_RULE_REASON_SUFFIXES with ] . Neither parses the reason.
  • The display_safety commit is gone. Four display tests now take the tag from the redactor output with its exact suffix removed, because that output is no longer the tag alone.

The body and the screenshots describe the new form. Locally, 505 test files ran with 30,139 passed. The 79 failures are test_enterprise_policy_fetch.py, test_cloud_source_staging.py and test_kas_bundle.py, which need a Kiro sign-in, a / owned by the runner and the KAS engine that this sandbox lacks. tsc, the nine blocked-link vitest files and the Slack golden tests pass.

@bolichen97

Copy link
Copy Markdown
Contributor

Re-reviewed at 67da36d: the regex change I asked for is done, thank you.

  • messaging/display_safety.py is no longer touched, so its placeholder pattern is back to main's.
  • The widened _PLACEHOLDER_RE and EXFIL_RULE_REASONS_RE are gone from security/exfil.py.
  • The reason now follows the tag as fixed text, from EXFIL_RULE_LABELS / EXFIL_RULE_REASON_SUFFIXES, and readers compare it whole with startswith and replace instead of parsing it.

I searched the product hunks for the old names and for re. directly, and found none. The security direction is neutral: it labels a redaction and refuses nothing new.

What still blocks a merge is outside your control. Sensitive Change Review cannot pass on a fork PR that changes a sensitive path; its log says a maintainer has to re-open it from a branch of this repository. I am flagging that to the maintainers. Lint, ratchets and the AI lanes are still running on this head.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • issue (blocking): fixed reason text causes a safely redacted reply to be discarded

fixed in 98c5ecf: segment_flush._kept_removed_values now counts each removed value in both copies after _without_reasons, which replaces each exact ] (<reason>) from EXFIL_RULE_REASON_SUFFIXES with ]. _blank_tags uses the same helper, so the run-by-run check and the removed-value check see the same text. No pattern changed. test_reason_words_are_not_a_removed_value_kept_by_the_segment streams the reported deltas (?token=h removes h, then a long query that becomes heavy encoding in the whole text). It withholds the reply on 67da36d and saves it with the heavy encoding tag on 98c5ecf. Only fixed table text is removed before the count, so a removed value anywhere else in the reply still fails the segment closed.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

The review lanes did not publish on 98c5ecf. GPT 6.1 Review says "verdict not published": it reached a verdict for this head, but the lane's PR comment still shows 67da36d. Opus 5.5 Review says "review incomplete", and Security Scope Review says "no leg reported". None of these is a finding on the code. A fork cannot re-run a job, so if the lanes are still unpublished at about 03:15Z, I will push the same tree on a new commit date to run them again.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main (03dc8a1) with no behaviour change. The rebase had no conflicts and git range-diff shows the commit unchanged. It does two things. It picks up #30127, which fixed the main-red test_slack_code_channels_events.py (#30095) that failed Backend Tests (3.12, 7) on 98c5ecf. The new head also re-runs GPT, Opus and Security Scope, which did not publish on 98c5ecf. Locally, 304 test files ran, including that Slack file: 19,003 passed. The 54 failures are test_enterprise_policy_fetch.py and test_kas_bundle.py, which need a Kiro sign-in and the KAS engine that this sandbox lacks.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 1) failed on c3c2536 on one test out of 29,066: test_skill_view_mode_recovery.py::test_a_sidecar_the_ledger_cannot_take_is_kept_and_its_alias_goes[False], with assert 0 == 1. This PR changes no skill or ledger code, and the file passes 3 of 3 local runs on this head, 24 of 24 tests each run. I found no open issue for it. I am not pushing again for it. The GPT lane run 41971311948 is still in progress, and the Opus lane run 41971311862 ended without publishing to its PR comment.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

The GPT and Opus lanes on c3c2536 have finished, and neither published. GPT run 41971311948 failed at "Fetch authentic diff". Opus run 41971311862 failed at "Opus 5.5 discovery", and its log says the run produced no completed verdict and the comment lookup also failed. Both PR comments still name 67da36d. The lanes did not publish on 98c5ecf either, so a third push would likely not help. I am leaving the head as it is for the maintainer re-review. A re-run of these two runs would put this head's verdicts on the PR.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main (28cb680) with no behaviour change. The only conflict was _PACKAGE_LINE_BUDGET in test/test_security_gate_liveness.py: main raised the pin to 34,524 for the Railway consent host. The resolution keeps main's paragraph and pins the measured total, 34,413. That is lower than main's pin because #30279 shrank redaction.py without lowering it: main measures 34,376, and this PR adds the same 37 lines as before. git range-diff shows only that line changed in the commit. Locally, 814 test files ran with 45,325 passed. The 114 failures and 11 errors are all in files that need a Kiro sign-in, the KAS engine, the golden sets or host permissions this sandbox lacks. Three app-install tests among them fail the same way on main's tree. None of them is in redaction code.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Backend Lint & Type Check (3.12) failed on 9d75e84 with two F821 undefined name 'was_installed' errors in src/kiro_crew/apps/routes_registry.py, lines 239 and 376. That comes from main: #30628 and #30584 merged together, and both are in this PR's base. Main tracks it as #30761 and #30769, and #30762 fixes it. This PR does not touch routes_registry.py. The three app-install test failures I saw locally on this head have the same cause, and they fail the same way on main. Coverage Gate fails because a test job failed. I will rebase once #30762 merges.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main (7785e9c) with no behaviour change, to pick up #30762, which fixed the was_installed F821 that failed Backend Lint & Type Check on 9d75e84. The rebase had no conflicts. The one change to the commit is _PACKAGE_LINE_BUDGET, re-pinned to the measured 34,457: main's shell_normalizer_walk.py grew by 44 lines, so main measures 34,420, and this PR adds the same 37 lines as before. Locally, 273 test files ran, including the two app-install files that failed on the previous base: 14,890 passed. The 54 failures are test_enterprise_policy_fetch.py and test_kas_bundle.py, which need a Kiro sign-in and the KAS engine that this sandbox lacks. This push also re-runs the Opus lane, which ended "review incomplete" on 9d75e84.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 3) failed on efdd59f on one test out of 31,264: test_crewmate_feed.py::test_a_retired_question_refreshes_the_waiting_list_with_no_log_growth, with Failed: Timeout >120.0s. That is the open flake #24356, and I added this run to it. This PR touches no crewmate feed code, and the test passes 3 of 3 local runs on this head in about 2 seconds each. I am not pushing again for it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main (0b4e7fe) with no behaviour change. Two conflicts, both pins:

  • _PACKAGE_LINE_BUDGET in test/test_security_gate_liveness.py: main raised the pin to 35,036. The resolution keeps main's paragraphs and pins the measured total, 35,073, which is main's 35,036 plus the same 37 lines this PR adds.
  • The Slack golden digests in test/test_slack_handler_composition_contract_golden.py: main's values sit next to this PR's. The resolution takes main's, then re-pins linked_approval and linked_thread_routes_to_slot to the values with the reason after the tag. With an empty reason table, main's values for those two and for credential_redaction pass unchanged, so the reason is still the only change.

Since the last head, the commit also re-pins two expectations in test/test_agent_stream_tail.py, which #30854 added with the bare tag for a presigned link; they now include (credential). Locally, 159 test files ran, including every test file main changed since the last base that names the placeholder or the segment save: 10,639 passed. The 66 failures are test_enterprise_policy_fetch.py and test_kas_bundle.py, which need a Kiro sign-in and the KAS engine that this sandbox lacks.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Security Scope Review on eebb868 shows BLOCK only because "the per-platform reports could not be folded"; its own verdict is PASS with no regression confirmed. A re-run of that lane would settle it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Lanes on 9dfba42 that need a re-run: GPT 6.1 Review reached a verdict but did not publish it, Opus 5.5 Review ended incomplete with no PR comment, and Security Scope Review failed closed because it could not read the prior conclusion (0 newly refused on macOS, Ubuntu and Windows).

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Static Ratchet Gate and Fast Gate on 6823dc6 are red from main. test_pid_reader_ratchet.py::test_owner_marked_sites_match_the_recorded_count counts 9 owner-marked pid readers against a baseline of 8, and it fails the same way on main 69d3a9a because #32376 added one. It passes on this branch's own base, and this PR changes no pid reader. Fork PR Description and Publish readiness signal hit the CI-app rate limit at 05:12Z, and both Build Desktop jobs failed on a 504 from the Electron download. I will push again once the ratchet is green on main.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

1f0ba60 has the same tree as 9a39879 (56ed0d15cf94) and no code change. It re-triggers two lanes. Await Fast Gate hit the CI-app rate limit at 03:58Z while it read the Fast Gate verdict, which itself passed, so every test job was skipped and Coverage Gate failed closed. The Security Scope Review generate job did not finish, so no leg ran.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 7) on 1f0ba60 (job 129639053080) needs a re-run. test_subagent_continuable_runs.py::test_default_cwd_continuation_does_not_request_override[changed-default] got conversation_busy: ... still settling a state write instead of the expected refusal, which is a timing race. The file passes 3 of 3 runs on main 74c2827 and 3 of 3 on this head, and this PR changes no subagent code. Coverage Gate failed only because shard 7 did.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

These lanes on 3f0547b need a re-run. GPT 6.1 Review run 42961430536 reached a verdict but did not publish it, because its GitHub API calls hit the installation rate limit at 04:52Z. Opus 5.5 Review run 42961430560 failed closed after its validation step got "API rate limit exceeded for installation" at 04:52:24Z. Security Scope Review run 42961430533 had no leg rows to combine, because the ubuntu-latest leg did not connect to github.com port 443 during checkout at 04:51:11Z.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own.

The placeholder keeps main's exact tag shape and gains a reason looked up from a fixed table by rule id, so no URL text reaches it. No blocking pattern, threshold, order or exemption changes. Every in-tree reader of the tag (restore_allowed_links, display_safety._REDACTION_TAG, segment_flush's placeholder regex and _links_main_shows, pass_compose, the renderer counters, the frontend BLOCKED_LINK_PLACEHOLDER_RE) matches by prefix, substring or main's pattern, so the suffix breaks none of them. Restoring an allowed link removes only that record's own reason, matched exactly; old rows without a reason are left as they are, and credential links are never restored. The segment-save check strips the fixed reasons from both copies, so a chunk boundary that trips a different rule doesn't withhold the reply, and a removed value that contains a tag is still counted. The new tests would fail without the change, and the existing tests I left unchanged only check substrings or the prefix. Approve, with notes on rendering polish and the pending CI.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 564bf30d76 · 564 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Coverage Gate on 958fe50 (run 43027461377) needs a re-run. It failed because website/src/linkPreview/textPatternWorker.ts showed 0.0% (0/11). This PR does not change that file. Its only website files are Redaction.stories.tsx and MarkdownRenderer.blockedLink.test.tsx, and the same two files passed this gate on 22bb3d7 (run 42991329695). The worker file came in with #26479 on 10-31 and has not changed since.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Run 43089712565 needs a re-run of Backend Tests (3.12, 1) to (3.12, 5), Frontend Tests (2) and Coverage Gate. Shards 1 to 4 and Frontend Tests (2) passed their tests and then failed at artifact upload with Failed to CreateArtifact. Shard 5 hit flake #35553. Backend Tests (3.12, 8) fails on main at this PR's base 3703c2e (#35534, fixed on main by #35541), so a re-run will not clear it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Run 43295424524 needs a re-run. Its Await Fast Gate job failed on the installation API rate limit at 19:57Z, so every test job in that run was skipped and Coverage Gate failed closed. Dependency License Gate (run 43295424521) and Publish readiness signal (run 43295417057) failed on the same rate limit.

A blocked link now reads [REDACTED: suspicious URL to <host>] (<reason>),
with the reason looked up from a fixed table keyed by rule id, so a reader
can tell a likely secret from a shape heuristic. The tag keeps its old shape,
so no pattern that reads it changes. The two readers that need the reason
compare the whole suffix against the fixed set: restore_allowed_links drops
the restored record's own reason, and the chat segment save drops it before
it compares the streamed copy with the whole-text copy.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blocked-link placeholder does not say which rule removed the URL

5 participants