Repository navigation
fix(security): allowed link hosts take DNS names only and audit their use - #18180
Pearcekieser wants to merge 1 commit into
Conversation
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The change only narrows what the allowed-host list accepts and only adds audit records. Every reader of Notes
[DESIGN-REVIEWED] eb3dd59 Description read[DESCRIPTION-READ] 56f4b5aee5adcaf2cf2331580da5bffdbc92f745b798acbc62259da298182967 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 |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The committed screenshots show the new "Only a host name like example.com can be allowed" line in light and dark, and the before and after states. No blind reader has read them, because this is the fork lane. Notes
[UX-REVIEWED] eb3dd59 Description read[DESCRIPTION-READ] 823275d5a42f55f6ebfc2031447ece66cf05cff0995daea0e25d0dfb5bf857fa That sha256 names everything this verdict read: the PR description, plus the 8 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 |
GPT 6.1 Review (fork) — ✅ no blocking findings (all downgraded on adjudication)Reviewed Opus 5.5 adjudication downgraded every blocking finding. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents. Review detailsBLOCKING -- src/kiro_crew/security/exfil.py:1040 -- Background memo fills audit links never displayed (origin: validation)
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — LOW. The conditions all check out in the code. The allow list is empty until it loads ( The use is still audited: one |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item answers part of the frozen Goal. Two pieces of the use-audit dedupe go further than the Goal needs. Notes
What this change shipsInventory (10 items) — 8 justifiedIntent: stop an operator from allowing a link host that names one machine, such as an IP or loopback address, and record in the audit log each time an allowed host puts a blocked link back on screen. This is a FIX (narrowing) plus an ADDITION (the audit).
[FIRST-PRINCIPLES-REVIEWED] eb3dd59 Description read[DESCRIPTION-READ] ca2f96dadd3717a29223bc1f3e49eb0746d6bf89827bafc3b589c86d50e91bd4 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
Security Scope Review (fork) — ✅ PASSWhich legitimate operations does adjudicated, zero confirmed regressions Scope-Verdict: PASS Reason: The change tightens the dashboard's allowed-host validator, which the shell deny composite never reads, so none of the 14 shell candidates should flip. No script verdict is attached to this review, so this does not claim any were measured. The validator now refuses IP literals, ports, underscores, overlong top-level labels and TIGHTENING: the redaction allow-list host validator ( ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix and windows rows. The diff changes no shell-side path, separator, executable or environment assumption. Its only platform-relevant code is in Python and TS and does not depend on the host OS. The rows probe the shell exfil tier: posix UNADJUDICATED: Guard:
In each newly refused case the reader still has Open once, which the new [SCOPE-REVIEWED] eb3dd59Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. |
|
issue (fixed): one regex now defines the operator-trusted DNS-host shape
|
|
suggestion (fixed): the card's host regex is pinned to the backend one
|
|
issue (fixed): the IP-host card now explains the missing Allow
|
|
suggestion (fixed): one line under the buttons says what happened and what to do
|
|
note: Sensitive Change Review needs a maintainer takeover This PR changes |
|
note: the two Integration (in-process gateway) failures on 0b7beb5 are outside this diff The diff touches the redaction allow list,
No code change is needed for either. The maintainer takeover requested above will rerun CI on the repository branch. |
0b7beb5 to
63d2160
Compare
|
issue (fixed): the hint now gives a reason that is true for every refused host
|
|
suggestion (fixed): the hint quotes the button name
|
|
nitpick (fixed):
|
|
thought (non-blocking): the hint text is staying as it is in this PR
|
|
thought (non-blocking): rewriting Design Review passed on 6e2cf6d and noted that a dropped IP-literal entry stays as bytes in |
|
chore (non-blocking): rebased on main as 561d209, no behaviour change The only conflict was |
|
@iamwhatever could you re-review 561d209 and clear the 10-21 change request? Your r124 hold on db84a34 (10-24) found the r117 points handled. Since then the head has only been rebased onto main. I checked After that, what is left is your r124 items 1 and 2, which only a maintainer can do: a human security review, and carrying the change on a repository branch so |
|
note (non-blocking): Security Scope Review red on 561d209 is the lane's own failure, not a finding The check run reads |
|
note (non-blocking): Backend Tests (3.12, 4) red on 561d209 does not reproduce on main merged with this PR The two failures are |
|
chore (non-blocking): rebased on main as 7c293e3, no behaviour change The only conflict was @iamwhatever this replaces 561d209, the head cruisercohen asked you to re-review. The patch is unchanged apart from that budget line. |
|
note (non-blocking): Backend Lint & Type Check red on 7c293e3 is a main defect already fixed on main The one error is |
|
chore (non-blocking): rebased on main as 1415978 to pick up #24767, no behaviour change Backend Lint & Type Check failed on 7c293e3 on |
|
note (non-blocking): Backend Tests (3.12, 2) red on 1415978 is a main defect The one failure is |
|
chore (non-blocking): rebased on main as fa32b2b, no behaviour change Main raised |
|
chore (non-blocking): rebased on main as d5d2e63, no behaviour change Main raised |
|
chore (non-blocking): rebased on main as c59ea20, audit emit moved into #20487's restore loop Main's #20487 rewrote The spec line keeps main's new restore wording and adds this PR's host-shape sentence unchanged. The line budget becomes main's 32,668 plus this PR's 197, giving 32,865. |
|
chore (non-blocking): rebased on main as 5a4ed26, no behaviour change Main raised |
|
thought (non-blocking): the The Opus note is right that this PR grows The GPT 6.1 finding, a background fill after restart recording a link nobody viewed, is the same path answered in 6364571821 and tracked in #53. Adjudication downgraded it again on this head. |
|
note (non-blocking): Security Scope Review on 5a4ed26 failed with no verdict, not a regression The check reports |
|
chore (non-blocking): rebased on main as 6ce301a, no behaviour change Main raised |
|
@iamwhatever the first two points of your change request look addressed at the current head 6ce301a. The in flight render race is fixed in this PR: a render now carries the revoke epoch it read, a stale scope is audited but not remembered, and a new test covers it. The Settings note for dropped hosts is tracked in a separate issue linked in the description. That leaves your third point, the manual security review of the redaction exemption change, since the fork cannot pass that check on its own. Could you do that review now, or say how you would like it carried? |
|
chore (non-blocking): rebased on main as e0e0198, no behaviour change Main raised |
|
note (non-blocking): Security Scope Review on e0e0198 has no verdict, not a regression The check reports |
|
chore (non-blocking): rebased on main as 953790e, no behaviour change Main raised |
|
chore (non-blocking): rebased on main as 635749d, no behaviour change Main raised |
|
note (non-blocking): Security Scope Review on 635749d has no verdict, not a regression The check reports |
|
chore (non-blocking): rebased on main as b7bde95, no behaviour change Main raised |
|
note (non-blocking): Opus 5.5 Review and Internal Content Scan on b7bde95 have no verdict, not findings Opus 5.5 Review reports "review incomplete" and Internal Content Scan reports "NO VERDICT, the scan did not run to completion", so neither lane judged this head. On 635749d both reached a verdict: Opus found nothing and the content scan was clean. b7bde95 differs from that head only in |
… use The allowed-host list accepted IPv4 and bracketed IPv6 literals and underscores. An address names one machine, often a loopback or private one, rather than a site the reader vouches for. The host check now takes lowercase DNS names with a letter TLD only; an off-shape entry already in the file is dropped on load, and the blocked-link card offers no Allow for such a host. Adds and revokes were audited, use was not. restore_allowed_links now writes one redaction_allowed_host_used SEL event per host per process when an allowed host puts a blocked link back on screen. Also: one DNS-host regex for both operator lists; explain a missing Allow. The allowed-link-host list now validates against exfil._OAUTH_EXTENSION_HOST_RE, unchanged from main, instead of its own copy, and also refuses *.localhost names, which browsers send to loopback without a lookup (RFC 6761 6.3). The refusal sits in valid_host and the card's isAllowableHost, so the OAuth list's shape is unchanged. A parity test pins the card's copy of both. A card whose host the list refuses says why where Allow would sit. A load that drops saved entries now logs one warning and writes one redaction.allowed_hosts.dropped_invalid SEL event per file per process. The use event names the render scope's workspace and its memo is keyed by (workspace, host); a revoke forgets the host and bumps an epoch the render memo keys on, so a re-allowed host is audited again. One lock guards that memo, so a revoke and a render cannot race on it. Both operator-list events share one SEL helper, the per-process audit memo has a count ceiling, and the security package line budget records the growth. After the exfil split in kirodotdev#22158, the shared SEL helper _log_operator_list_use lives in exfil_oauth beside the OAuth use event, and the facade imports it. The save-time display-verdict projection restores links under allowed_host_use_unaudited, so a render nobody reads writes no use event and leaves the memo for the reader's first real view. Allowed link hosts keep the 63-letter cap on the top-level label, beside the shared regex, as the list did before it shared that regex.
|
chore (non-blocking): rebased on main as eb3dd59, no behaviour change Main raised |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed head eb3dd59 against b7bde95 with range-diff. This is a rebase only:
_PACKAGE_LINE_BUDGETis 33,344, which is main's 33,147 plus this PR's unchanged 197.- The
exfil.pyimport hunk only differs in context, because main now importsAnybesideTYPE_CHECKING. - No other hunk of this PR changed, and I found no new issue in the delta.
Status of the open request for changes:
- Point 3 still applies on this head and cannot be cleared by a push from the fork. The PR changes which hosts are exempt from redaction, and
Sensitive Change Reviewstill fails because a fork PR cannot pass it. This needs a maintainer decision on carrying it on a repository branch, plus a human security approval. - The
merge conflictlabel is stale: GitHub reports this head as mergeable.
No approval from me, because of point 3.
|
This change is now carried on a repository branch in #26736, so the required @iamwhatever, could you review #26736? Point 1 of your request is fixed in the carried code, point 2 is linked under Related Issues, and point 3 is why the new PR exists. It still needs a second maintainer approval and a human security review. This PR stays open until #26736 lands. |
|
note (non-blocking): closing in favour of #26736, which merged this change #26736 merged on 2026-10-31 as 817316f. |
Problem / Motivation
Goal: The allowed link host list holds DNS names only, and every time an allowed host lets a blocked link back on screen the security audit log records it.
The allowed-host list from #12684 accepts IPv4 and bracketed IPv6 literals. The blocked-link card offers "Allow for this host" on a link to
10.0.0.5, and one click relaxes the query-length and base64 checks for that address. The add and revoke routes write SEL events, but nothing records when an allowed host actually restores a link.Why it matters
An IP literal names one machine, often a loopback or private one where the reader's own control planes run, and an injected reply can aim a long-query link there. The OAuth endpoint extension, the other operator-trusted host list in
exfil.py, already refuses IP literals. Without a use event, an operator reviewing the audit log can see that a host was allowed but not whether the allowance ever let a link through.Not a goal
127.0.0.1.nip.io, still passes the shape check. The card shows that name to the reader before they allow it, but nothing here refuses it on the address.What changed (motivation → approach → change)
_HOST_REinredaction_allow.pymatched IP literals and accepted any run of[a-z0-9._-]. It is now_OAUTH_EXTENSION_HOST_REitself, which lives inexfil_oauth.pysince the exfil split in #22158, the regex the OAuth endpoint extension already validates its hosts with, so the two operator-trusted host lists share one definition. The OAuth regex itself is unchanged.valid_hostalso refuses a name whose last label islocalhost, because browsers send every*.localhostname to loopback without a lookup (RFC 6761 section 6.3); the refusal sits beside the shared regex, not in it, so the OAuth list's shape does not change. Beside it too,valid_hostkeeps main's 63-letter cap on the top-level label (MAX_TLD_LEN), because the shared regex leaves that label open-ended.allow_hostrefuses anything else. An off-shape entry already inhosts.jsonis dropped on load, so the file can never widen trust past whatallow_hostwrites. The first load of a file in a process that drops entries logs one warning and writes oneredaction.allowed_hosts.dropped_invalidSEL event with the exact count and up to 50{workspace, host, reason}entries, so a narrowed list shows in the audit log.RedactionCards.tsxcarries a copy of that regex and of the.localhostrefusal to hide "Allow for this host" when the server would refuse the host, andtest_redaction_mirror_parity.pyderives the expected copy from the backend regex and checks the suffix againstredaction_allow.LOOPBACK_SUFFIX, so the two cannot drift. In Allow's place the card says "Only a host name like example.com can be allowed. Use “Open once” instead." The wording covers every host the list refuses, an underscore name as well as an IP literal. Before this change the button was offered for an IP-literal host.restore_allowed_linksinexfil.pynow writes oneredaction_allowed_host_usedSEL event per workspace and host per process when it puts a link back. It and the OAuth extension's use event write through one shared helper,_log_operator_list_useinexfil_oauth.py, and_PACKAGE_LINE_BUDGETintest_security_gate_liveness.pyrises by 197 lines over main's value to record the growth, from 32,616 to 32,813 on head 1415978. The event names the workspace, the host and the rules relaxed. The workspace comes from the render'sscoped_exempt_hostsscope, which the three render paths now open with the slot's stored workspace key, and a revoke forgets the host and bumps an epoch thatwire_render._context_digesthashes with the scoped workspace, so a memoized history render misses once and the host's next use after a re-allow is audited again. One lock,_ALLOWED_HOST_AUDIT_LOCK, guards the memo and the epoch, so a revoke iterating the memo cannot race a render adding to it. Each render path readsallowed_host_audit_epoch()beforeallowed_hosts_forand passes it toscoped_exempt_hosts. If a revoke lands between that read and the audit, the epoch no longer matches under the lock, so the render's use is audited but not remembered, and the first use after a re-allow is still audited. The render memo key hashes the same scoped epoch. The save-time display-verdict projection indisplay_verdicts.projectrenders every saved row in the background to store its verdicts, and it runs underallowed_host_use_unaudited, so a render nobody reads writes no event and leaves the memo free for the reader's first real view. It follows_emit_oauth_extension_used_event: deduped per process, best-effort, and a failed write never blocks the restore. The dedupe memo holds at most_ALLOWED_HOST_AUDITED_MAX = 1024workspace and host pairs. Past that, a new pair is audited on every restore and not remembered, so revoked hosts cannot grow it;test_the_audit_memo_stops_growing_at_its_ceilingcovers both sides.The security argument is that this change only narrows what the list accepts and only adds audit records. No URL that was blocked before is let through.
docs/system-specs/modules/security.mddocuments the host shape and the new event.Backwards compatibility
Breaking: an IP-literal, underscore or
*.localhosthost saved in<config>/redaction-allow/hosts.jsonis no longer honoured, so links on it show as blocked again. Writer sweep on origin/main @ 8625baa:allow_hostis the only writer, reached only fromapi_redaction_allow_host, which validates with the samevalid_host. A dropped entry is never honoured and Settings does not list it, and the load that drops it writes theredaction.allowed_hosts.dropped_invalidSEL event and a warning.revoke_hostcannot target it, because it works from the filtered snapshot and returns False for a host that is not there. The entry stays as dead bytes inhosts.jsonuntil the next allow or revoke in any workspace, which rewrites the file from the filtered snapshot and removes it.Release notes should say that a link host saved as an IP address, with
_in its name, or under.localhostis no longer allowed, and that the reader can use "Open once" or allow a DNS name for that machine instead.Reader: src/kiro_crew/security/redaction_allow.py:allowed_hosts_for -- chat -- returns only valid hosts; test_a_dropped_entry_left_in_the_file_is_logged_and_audited_once
Reader: src/kiro_crew/security/redaction_allow.py:list_allowed -- crew page -- Settings list shows only kept hosts; same test
Reader: src/kiro_crew/dashboard/handlers/redaction.py:api_redaction_allow_host -- crew page -- returns 400 invalid_host for an IP literal; test_ip_literals_ports_and_wildcards_are_refused
Tests
test_ip_literals_ports_and_wildcards_are_refusedcovers 13 off-shape hosts: IPv4, IPv6, IPv4-mapped IPv6, a port, a wildcard, leading and trailing hyphens, an underscore, an empty label, a bare name and two*.localhostnames. Each is refused byvalid_hostandallow_host.test_a_dropped_entry_left_in_the_file_is_logged_and_audited_oncechecks that a hand-edited file with an IP literal, a.localhostname and a number keeps only its DNS entry, and that the load writes one warning and one SEL event naming all three with their reasons, not repeated when a write re-reads the file.test_restoring_an_allowed_link_is_audited_once_per_hostchecks that an unlisted host logs nothing, that three restores in one workspace log one event with the workspace, host and rule, that the same host in a second workspace logs its own event, and that a revoke makes the next use log again.test_a_re_allow_after_a_revoke_misses_the_memo_and_audits_againrenders throughwire_render.prepare_messages_jsonand checks one event per workspace, a memo hit on the second render, and a fresh event after a revoke. It fails on the previous head.test_a_save_projection_audits_no_allowed_host_userunsdisplay_verdicts.projecton a row with an allowed link and checks it writes no event, then that the reader's render writes one. It fails withoutallowed_host_use_unaudited.test_a_render_whose_snapshot_predates_a_revoke_is_not_rememberedtakes the epoch and hosts, revokes, then restores under that stale scope. It checks the link is shown and audited with the memo left empty, and that the first view after a re-allow is audited and remembered. It fails without the epoch check.test_a_failing_audit_does_not_stop_the_restorechecks that a raising audit log still restores the link.MarkdownRenderer.blockedLink.test.tsxchecks that cards for10.0.0.5,[::1],my_box.corp.exampleandapi.localhostrender no Allow button and show the host-name hint, and that a DNS-host card shows no hint.test_blocked_link_card_offers_allow_only_for_hosts_the_server_acceptspins the frontend regex and.localhostsuffix to the backend ones.Manual verification
website/scripts/capture-blocked-link-allow-host.mjsdrives the built SPA with fixtures: one reply holds a blocked link onreviews.corp.exampleand one on10.0.0.5. On main both cards had one Allow button. On this branch the DNS card has one, and the IP card has none and shows the host-name hint instead, in dark and light themes.Screenshots / video
On main, the IP-host card offers Allow:
On this branch, the IP-host card has no Allow and says why:
On this branch, the DNS-host card keeps Allow:
Related Issues
Follows #12684.
Follow-up: Pearcekieser/KiroCrew#52 tracks a Settings note when a load drops saved hosts. Pearcekieser/KiroCrew#53 tracks writing the use audit when a background-filled fragment is first served rather than when it is rendered, from the GPT 6.1 finding on bc6fe06. Upstream issues here open together with their PR, so the upstream issue opens with that PR.
Pattern harvest
Rule candidate: review-prompt
Pattern: an operator-trusted host list whose host regex accepts IP literals or loose character runs instead of the shared DNS-name shape
Checklist
Fixes #18179