Repository navigation
fix(security): allowed link hosts take DNS names only and audit their use - #26736
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change only narrows what the host list accepts and only adds audit records, and the readers it affects are listed with tests. Notes
[DESIGN-REVIEWED] 9f770f2 Description read[DESCRIPTION-READ] 06f8f1b87d95ed160123b63cb5f6062fca9c4ee898d74dfad498c2f59b3aaae2 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item either narrows what the allowed-host list accepts or adds an audit record. The use-audit memo, epoch and lock are there because the review on #18180 asked for the race fix. What this change shipsInventory (10 items) — 10 justifiedIntent: stop one click on the blocked-link card from trusting an IP or loopback address, and let an operator see in the audit log when an allowed host put a link back on screen. FIX, with an audit addition that the Goal covers.
[FIRST-PRINCIPLES-REVIEWED] 9f770f2 Description read[DESCRIPTION-READ] 38ae75c03b0085ac841c72717be7db80a0bc074d88f2514848f78feeea8d27f1 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. Screenshots 02 and 04 show the new note in place of the missing Allow button for an IP host, in both themes. The blind reader understood what the note means. Notes
[UX-REVIEWED] 9f770f2 Description read[DESCRIPTION-READ] 2f6726ae03d1c38e3da334c55bd12b8ca3af423d7f4432e0f9c0b9ee5406a816 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Sensitive change review
|
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: This change tightens the dashboard's allowed-host validator ( TIGHTENING: the allowed-host list's host-shape validator -- it refuses IP literals and ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: Candidates cover posix and windows. The diff adds no path, separator, interpreter or environment assumption to any shell tier. The only platform-shaped code it touches is the allowed-hosts file load, which goes through
The rule this change tightens is a host-shape rule with no platform dependence, so no platform assumption is left unprobed. UNADJUDICATED:
[SCOPE-REVIEWED] 9f770f2 |
… 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 #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. Carried from #18180 on a repository branch so the change can take a human security review. Co-authored-by: Pearce Kieser <5055971+Pearcekieser@users.noreply.github.com>
ae76c47 to
9f770f2
Compare
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
Adding hosts from Settings, or one list for the whole deployment. Those are a separate follow-up.
Applying the list outside the dashboard. Slack and other channels unfurl links with no click, and the list only allows a link to be opened on a click.
Checking what a host name resolves to. A DNS name that resolves to loopback or a private address, such as
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.Changing which checks an allowed host skips. Credential, encoded-credential, decode-saturation and percent-encoding checks still run for every host.
Timing the use event to the frame the reader sees. The slot-detail memo fill renders the page a reader just opened and is audited, so its event can land a second before the link shows, never after.
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. The hint is one new key in eachwebsite/src/i18n/locales/*.jsoncatalog. 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, naming the workspace, the host and the rules relaxed. It shares_log_operator_list_useinexfil_oauth.pywith the OAuth extension's use event, and_PACKAGE_LINE_BUDGETintest_security_gate_liveness.pyrises by 197, from 33,523 to 33,720. The workspace comes from the render'sscoped_exempt_hostsscope, which the three render paths open with the slot's stored workspace key. A revoke forgets the host and bumps an epoch thatwire_render._context_digesthashes, so a memoized render misses once and the next use after a re-allow is audited again. One lock,_ALLOWED_HOST_AUDIT_LOCK, guards the memo and the epoch. Each render readsallowed_host_audit_epoch()beforeallowed_hosts_for; if a revoke lands in between, the use is audited but not remembered. The save-time projection indisplay_verdicts.projectruns underallowed_host_use_unaudited, so a render nobody reads writes no event. The event is best-effort and a failed write never blocks the restore. The memo holds at most_ALLOWED_HOST_AUDITED_MAX = 1024pairs; past that a new pair is audited every time and not remembered.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 @ 770088c: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
Carried from #18180
This is #18180 by @Pearcekieser, carried on a repository branch with no behaviour change. #18180 comes from a fork, so its required
Sensitive Change Reviewcheck cannot pass there. The one commit is #18180's head eb3dd59 cherry-picked onto main ac346e0 and later rebased onto 770088c, withCo-authored-by:the original author. The only conflict was the_PACKAGE_LINE_BUDGETline: the resolution keeps main's comment and adds this change's unchanged 197 lines, giving 33,720.How each point of the request for changes on #18180 is handled:
allowed_host_audit_epoch()beforeallowed_hosts_for, and a use whose epoch no longer matches under_ALLOWED_HOST_AUDIT_LOCKis audited but not remembered.test_a_render_whose_snapshot_predates_a_revoke_is_not_rememberedcovers it.hosts.jsonentries. Tracked in Pearcekieser/KiroCrew#52, linked under Related Issues.Sensitive Change Reviewcan run here. It still needs a maintainer approval and a human security review before it merges.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.Determinism: the four changed backend test files passed 5 runs in a row with
-n 8, and once serially in reverse file order. With the production files reverted to main, 19 of their tests fail.Proof: not provable -- other: prove.py cannot revert the binary screenshots in this diff; reverting the src/ files to main by hand fails 19 of these tests
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.
Sibling sweep
Swept: git grep -nE "allow_host(|hosts.json|_HOST_RE" -- src/
Sibling: src/kiro_crew/security/exfil_oauth.py -- changed here
Sibling: src/kiro_crew/apps/manifest_contributes.py -- not affected -- app manifest host list, not an operator redaction exemption
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
Supersedes #18180
Contribution License Agreement
Contributed under the project's Apache-2.0 license.