Skip to content

fix(security): keep links whose path is encoded words - #22571

Merged
bolichen97 merged 1 commit into
mainfrom
fix/exfil-path-text-22498
Oct 21, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/exfil-path-text-22498

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A link whose path is words in Chinese, Japanese, Russian or another non-ASCII script shows as a link in chat instead of a blocked-link card.

A news link like https://hk.finance.yahoo.com/news/<Chinese headline>.html is shown as [REDACTED: suspicious URL to hk.finance.yahoo.com] with rule exfil_percent_encoding (#22498). The browser writes each Chinese character as three percent-encoded bytes, so seven characters already make the 20+ byte run the heavy percent-encoding rule flags.

Why it matters

Anyone who reads or shares links in a non-Latin script hits this on ordinary news, wiki and shop links. The card hides the link they asked for, and it teaches people that the redactor is noise.

Not a goal

  • The query string. Encoded words in ?q=... stay flagged, as today.
  • The OAuth banner admission gate. It keeps the strict rule.
  • The frontend mirror (website/src/utils/sanitize.ts). It never percent-scans the path, so nothing there changes.
  • Any other exfil rule (credentials, base64, query length).

What changed (motivation → approach → change)

A path run of percent bytes is skipped by the heavy percent-encoding rule only when it is words: every byte non-ASCII, strict UTF-8, and every character a letter, mark, number or punctuation whose NFKC form is not an ASCII letter or digit.

Run in the path Before After
Chinese / Japanese / Cyrillic words flagged kept
Encoded ASCII (%41%41...), even one byte inside words flagged flagged
Fullwidth AKIA..., invisible, private-use, space, bad UTF-8 flagged flagged
Same words in the query, or on the OAuth gate flagged flagged

This opens no new channel. The path gets no base64 or length check today, so the same words, or any ASCII text, written unencoded already pass. The rule lives in security/exfil_url_rules.py (_heavy_percent_encoding); security/exfil.py calls it. The security spec gains one bullet. The security package line budget rises by the 37 new lines.

Backwards compatibility

Compatible: the change only stops flagging one shape that was flagged before; nothing that renders today stops rendering.

Removes nothing: the change narrows when a link is hidden; no record, field, key or function is removed.

Tests

  • test/test_exfil_path_text.py (new): the reported Yahoo link and Japanese, Russian and punctuated Chinese paths are kept; encoded ASCII, ASCII inside a word run, fullwidth letters, invisible, private-use, ideographic space and non-UTF-8 runs in the path are still redacted; Chinese words in the query are still redacted; the OAuth admission gate still rejects a Chinese path. Red on main (the kept cases fail), green here; the OAuth case is red if the gate is given the waiver.
  • test/test_redaction_blocked_links.py::test_a_cjk_title_link_keeps_its_whole_address: it relied on a Chinese PATH being blocked. The title moves into the query, which is still blocked, so it keeps testing that a blocked link keeps its whole address.
  • test/test_security_gate_liveness.py: budget raised from 32,060 to 32,097 (this PR's 37 lines on top of main) with its reason.

Manual verification

N/A — unit coverage sufficient: the rule is a pure function of the URL text, and the tests drive the real redact_exfiltration_urls and oauth_url_contains_credential entry points with the reported URL.

Related Issues

Closes #22498

#21573 (merged) also raised the same line budget; this PR is rebased on it and adds its 37 lines on top.

Pattern harvest

Rule candidate: review-prompt
Pattern: a byte-run heuristic on percent-encoded text must say whether the bytes decode to words before calling them a payload.

Sensitive change review

Draft for a maintainer other than the author to verify and paste into an approval on the current head.

  • What rule changed: _exfil_url_warning heavy percent-encoding rule skips a PATH run that decodes to non-ASCII words.
  • Before -> after (what was allowed/blocked, now): a link with 7+ CJK characters in its path was blocked as exfil_percent_encoding; now it renders. Encoded ASCII, fullwidth letters, invisible or private-use characters, invalid UTF-8, any run in the query, and the OAuth admission gate are blocked as before.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a model hides data as non-ASCII letters in a link path. That already passes today when written unencoded, because the path has no base64 or length check, so no new leak path opens.
  • Evidence checked: test/test_exfil_path_text.py red on main and green here; the OAuth case turns red when the gate gets the waiver.
  • No regression:
    • Tools still work: no command, tool or gate path changes; only URL classification.
    • Backward compatible: only one previously blocked shape now renders.
    • Existing tests: the related backend set passes; one test moved its title into the query to keep its point.
  • How to undo: revert this commit; the rule returns to flagging every 20+ byte run.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 20, 2026 20:57
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/exfil.py

  • src/kiro_crew/security/exfil_url_rules.py

  • @iamwhatever: missing the ## Sensitive change review heading

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 2082c0e54d155983fb658f024cb7a342f0fb1664
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No design-level concerns. The waiver covers only encoded words in the path, which already pass when written unencoded. The query and OAuth gates stay strict.

[DESIGN-REVIEWED] 2082c0e

Description read

[DESCRIPTION-READ] f544ca3f68c6c604e2e8eb39fe57dc82470219dd39c5d8f2c99ae6a8d4056161

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

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 2082c0e54d155983fb658f024cb7a342f0fb1664 — 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. This is a scoped fix for #22498, and the new tests fail on base. The rewritten CJK test was checking the blocked link's record, not deciding that CJK paths must be blocked.

What this change ships

Inventory (6 items) — 5 justified

Intent: a link whose path is non-ASCII words (Chinese, Japanese, Russian) shows as a link in chat, not as a blocked-link card. FIX.

  1. Links whose path is percent-encoded words in a non-Latin script now show as links instead of [REDACTED: suspicious URL] — justified
  2. Encoded ASCII, fullwidth letters, invisible, private-use or space characters and invalid UTF-8 in the path are still blocked — justified
  3. Encoded words in the query, and the OAuth admission gate, stay strict — justified
  4. test_a_cjk_title_link_keeps_its_whole_address moves its title into the query so the link is still blocked and the test keeps its point — justified
  5. The security package line budget rises by 37 lines, and the security spec gains one bullet — justified
  6. _is_encoded_path_text is added to the exfil.py type-checking re-export list — undeclared; no runtime consumer, it only completes the facade list

[FIRST-PRINCIPLES-REVIEWED] 2082c0e

Description read

[DESCRIPTION-READ] b6c9dd33e3ffbe1ad70b8c355806e579dc9f646d42d661bda70492e460eb9f4a

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 2082c0e

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

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

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2082c0e

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 20, 2026 21:05
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

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

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

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

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: This diff relaxes a rule rather than tightening one. _heavy_percent_encoding reports a match whenever the old _EXFIL_PERCENT_RE.search would have, and with allow_path_text=False (the OAuth gate) it gives the same result. With allow_path_text=True it can only drop matches, and only ones that lie entirely in the path. The shell deny composite (sensitive-bash, exfil = exfil_bash.audit_bash_exfiltration, deny-rules) does not call _exfil_url_warning, so the adjudicated set should return zero flips. The waived surfaces are text redaction and mcp_cron_vet.scan_exfiltration_urls, and nothing classifies those (named under UNADJUDICATED).

TIGHTENING: None. The only mechanism touched is the heavy percent-encoding detector inside _exfil_url_warning, and it was loosened: - if _EXFIL_PERCENT_RE.search(path_and_query): / + if _heavy_percent_encoding(path_and_query, allow_path_text=not allow_oauth_entropy):. A path-only run of non-ASCII UTF-8 words (a CJK headline) no longer counts as exfil_percent_encoding. Encoded ASCII, invalid UTF-8, Cf, private-use, space and fullwidth alphanumerics stay flagged, as do every query run and every run at the OAuth gate. bytes.fromhex only ever sees runs the regex has already restricted to %[0-9A-Fa-f]{2}, so the helper cannot raise and fail closed.

ADJUDICATED: 11 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: The diff itself makes no path, separator, executable or environment-variable assumption. Its only spelling-sensitive input is a URL percent run.

  • posix: curl and wget fetches with a CJK path (the Yahoo HK news case the PR names), plus a short CJK query below the 20-octet floor. Pytest runs over the touched tests.
  • windows: curl.exe with a double-quoted URL, to check that %XX runs are not read as %VAR% expansion. Invoke-WebRequest with a Cyrillic (2-octet) path. The venv .exe pytest run with backslash paths.
  • any: gh api with an encoded non-ASCII contents path, and kirocrew manifest --url, which shares the edited classifier.

No assumed platform went unprobed.

UNADJUDICATED:

  • Guard: exfil_url_rules._heavy_percent_encoding, reached through exfil._exfil_url_warning. It is only relaxed. Its call paths are:

    • redact_exfiltration_urls / redact_exfiltration_urls_with_records for chat display, pass_compose, and credential_sources.
    • scan_exfiltration_urls from mcp_cron_vet.py:484 (cron command vetting) and from apps/builtins/aws_control/backend/library.py:326.
    • oauth_url_contains_credential (line ~1171, allow_oauth_entropy=True). The strict rule is unchanged there.
  • Candidate inputs I could not get a verdict for:

    • a chat reply containing https://hk.finance.yahoo.com/news/<encoded headline>.html?guccounter=1, which should now render;
    • a cron job command curl -s https://ja.wikipedia.org/wiki/<encoded 東京都の歴史と文化>, vetted by mcp_cron_vet;
    • an aws_control library entry that embeds a CJK-path doc link.

    Because the guard only gets looser, none of these can be newly refused.

  • Unchanged neighbour: display_safety.py:61 still calls _EXFIL_PERCENT_RE.search(text) directly and keeps the old behaviour. That is a parity gap, not a refusal this diff introduces.

[SCOPE-REVIEWED] 2082c0e

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 20, 2026
@bolichen97
bolichen97 force-pushed the fix/exfil-path-text-22498 branch from d934b54 to ac1d8ca Compare October 20, 2026 21:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 20, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in docs/system-specs/modules/security.md since this head went green (2d455da -> 20bc3fc); CI re-running.

@bolichen97
bolichen97 force-pushed the fix/exfil-path-text-22498 branch from ac1d8ca to e4022d5 Compare October 20, 2026 23:00
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 20, 2026
@bolichen97

bolichen97 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Disposition: rebutted

  • span=8de40e9e2eef: query-only percent scanning is smaller

Encoded path payloads that query-only scanning lets through, but that cannot be written unencoded in a path: %20 spaces, %0A newlines, %22/%27/%29/%3E delimiters, and raw non-UTF-8 bytes.
_URL_RE ends a link at whitespace, ), ", ' and >. A multi-line file or a binary blob only fits in one link when it is percent-encoded. That is the channel _EXFIL_PERCENT_RE closes in the path.
Query-only scanning would drop that floor for the whole path. That loosens detection of real exfil, which this fix must not do.
_is_encoded_path_text admits only strict UTF-8 that is every byte >= 0x80, with letter, mark, number or punctuation chars that are not fullwidth ASCII. Those are exactly the chars a browser accepts unencoded in a path, so the waiver adds nothing the raw path does not already carry.
%41x25 stays flagged on purpose. An encoded ASCII run can hold every delimiter above, and splitting ASCII by class is a wider change than this false positive needs.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention labels Oct 21, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review lanes on the head carry CONCERNS (advisory) and no BLOCK; the watch holder read them and approved explicitly.

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 21, 2026
@bolichen97
bolichen97 force-pushed the fix/exfil-path-text-22498 branch from 3961dbf to 2082c0e Compare October 21, 2026 21:25
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 21, 2026
@bolichen97
bolichen97 merged commit 6e9766f into main Oct 21, 2026
108 of 110 checks passed
@bolichen97
bolichen97 deleted the fix/exfil-path-text-22498 branch October 21, 2026 23:07
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 21, 2026
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.

Redaction false positive: exfil_percent_encoding

3 participants