Repository navigation
fix(kas): add opt-in fail-closed for an uncarried web_fetch.blocked - #36329
Conversation
1d4ac32 to
1704e15
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The setting is opt-in and off by default, so the default path matches main. Turning it on only tightens fetches, and an operator can flip it back to undo it. Notes
[DESIGN-REVIEWED] 234056e Description read[DESCRIPTION-READ] 5e8d7bb73d24982754943a0fc9553e256f72d68773adb086c1aba16e163ee73f 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 The new opt-in key is off by default and is read by two call sites. KAS can't match a whole URL, which is the real cause; the description leaves that to #33068. Notes
What this change shipsInventory (3 items) — 1 justifiedIntent: let an operator have KAS refuse all web fetches rather than silently ignore a
[FIRST-PRINCIPLES-REVIEWED] 234056e Description read[DESCRIPTION-READ] 16f147da494b98cef4f737c7803a272bdda2eecbcf876fc5bac8f3d3bfbfa688 That sha256 names the PR description this verdict read. 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: |
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own. Adds an opt-in setting, agent.kas_fail_closed_web_fetch_blocked (off by default). With it on, a web_fetch.blocked entry KAS cannot carry turns that key's host denies into one KAS web_fetch deny over "*", and the session notice adds a refusal mark. With it off, the rules and the notice are unchanged from main for every spec. A KAS deny refuses the fetch before Crew's gate sees any request, so the gate's trusted-URL grant cannot bypass it. All three tools_settings_to_permissions callers (notice, projection, tool view) stay consistent. The config wiring copies kas_refuse_plain_http_mcp_headers in every place that setting appears. Tests cover both settings for three kinds of uncarried entry, the notice mark, and the config reader. Source Gates and Fast Gate are red, but I could not tie the failure to this diff. 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 |
1704e15 to
5c6024d
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on one part: the "*" fallback.
I agree with the goal. On main, a web_fetch.blocked entry KAS cannot carry is dropped. converted (acp/kas_permissions.py:1780-1790) puts it only on lost, and the web_fetch branch (:1890-1903) sends just the host denies it could build. So a fetch the user blocked still runs, and the notice is the only trace.
The fix overshoots that, though. blocked = ["*"] turns one uncarried entry into a deny over every URL. With blocked: ["https://evil\\.com/.*"], the agent can then no longer fetch docs.python.org or github.com, which the user never blocked and which kiro-cli fetches for that same spec. That makes a fetch fail where main and kiro-cli let it run, so it adds a refusal beyond what the user wrote.
Please:
- Keep main's translation by default for an entry KAS cannot carry: no rule from it, the other entries' host denies as before, and the notice naming it as not applied.
- If you want the fail-closed behaviour, put the
"*"deny behind an opt-in setting that is off by default, and have the notice mark say so only when it is on. - Keep the new test for the opt-in path, and add a default-path test where an uncarried entry adds no rule and the carried host deny still travels.
The rest is fine: the carried .*evil\.com.* case, the notice text change and the docs. No regex is added.
Not checked: I ran no tests locally. "Publish readiness signal" is red on this head, and I did not read its log, since I am not approving this round.
|
This PR asks the security owner to decide whether failing closed is right here. That decision stays with the security owner. No sign-off is recorded on the PR yet, so it waits for that decision before it can merge. Review result on head 5c6024d: no blocking findings. PR Readiness is green. The fix sits in the single writer ( For the security review:
Optional:
|
5c6024d to
6eb2e68
Compare
6eb2e68 to
530ea8d
Compare
On KAS a toolsSettings.web_fetch.blocked entry KAS cannot carry (a scheme or path, other regex syntax, too long) becomes no rule, and only the session notice names it. A new setting, agent.kas_fail_closed_web_fetch_blocked (off by default), turns that key into one KAS web_fetch deny over "*" and makes the notice say every fetch is refused. With the setting off, behaviour matches main.
530ea8d to
234056e
Compare
|
@bolichen97 ready for another look at 234056e. Your 08:06Z review is addressed:
All CI checks pass on this head; PR Readiness waits only on your review decision. The one Linux shard red was the tracked transcribe flake (#36364), green on rerun. |
bolichen97
left a comment
There was a problem hiding this comment.
Approving on 234056e. My point on the "*" fallback is fixed:
- By default an uncarried
web_fetch.blockedentry adds no rule, as on main. The carried host denies still travel, and the notice names the entry without the "every fetch is refused" mark.test_by_default_an_uncarried_blocked_entry_adds_no_rulepins this for the whole-URL, regex-syntax and over-long cases. - The deny over
"*"now sits behindagent.kas_fail_closed_web_fetch_blocked, which defaults to off.fails_closed_on_uncarried_blockedturns it on only for a JSONtrueand reads off when the config cannot be loaded, so a broken config keeps main's behaviour.test_fail_closed_is_read_from_the_agent_configcoverstrue,false,"true"and unset. The opt-in path and its notice mark have their own tests. - The setting is in
AgentConfig, the loader,config-baseline.jsonand the docs. - No regex.
Not checked: I ran no tests locally and relied on CI (97 green).
Problem / Motivation
Goal: Let an operator opt in to refusing every web fetch on KAS when a
web_fetch.blockedentry they set cannot be applied, so that entry is never silently ignored.On the KAS backend, a
toolsSettings.web_fetch.blockedentry that KAS cannot carry becomes no rule. That covers an entry naming a scheme or path, one using other regex syntax, and one that is too long. The session notice names it, but the fetch it was meant to block still runs.Why it matters
A user who writes
blocked: ["https://evil\\.com/.*"]expects that URL to be refused, as kiro-cli refuses it. On KAS the agent fetches it with no refusal. An operator who would rather lose all fetches than run with a deny that does nothing has no way to choose that today.Not a goal
blockedto fetches KAS's own policy allows by matching the whole URL.trusted/blockedentries beyond a plain URL or a plain URL plus.*.blockedmatch at Crew's gate, or any regex matching on URLs.What changed (motivation → approach → change)
Per @bolichen97's review (default stays as on main; the
*deny only behind an opt-in that is off by default), this adds one setting.agent.kas_fail_closed_web_fetch_blockedblockedentryfalse(default)trueweb_fetchdeny over*in place of its host denies; every web fetch is refused until this entry is fixedThe setting copies the existing
agent.kas_refuse_plain_http_mcp_headersopt-in: a field inconfig/sections_agent.pywith help text insections_agent_fields.py, read inloader_builders.py, and read at session start bykas_unread_commands.fails_closed_on_uncarried_blocked(only a JSONtrueturns it on; an unreadable config reads as off).kas_permissions.tools_settings_to_permissionsand the notice both ask that one reader. No regex is added.The
security.mdspec line, theagent-spec-fields.mdrow,configuration.mdand the generatedconfig-baseline.jsondescribe the setting. The settings label comes from the config schema; no website strings change.Backwards compatibility
Compatible: the setting is off by default, and with it off the translation and the notice are the same as main for every spec. Turning it on is the operator's choice; then an agent with an uncarried
blockedentry cannot fetch any URL until the entry is fixed.Removes nothing: the change adds one opt-in setting and changes no default.
Tests
test_by_default_an_uncarried_blocked_entry_adds_no_rule(whole-URL, regex syntax, over-long): setting off, an uncarried entry adds no rule, the carried host deny still travels, the key is named. Same as main.test_opted_in_an_uncarried_blocked_entry_denies_every_fetch(same three): setting on, oneweb_fetchdeny over*.test_opted_in_the_notice_says_every_fetch_is_refused: setting on, the notice item ends with the refusal mark. The existing notice tests pin main's text for the default.test_fail_closed_is_read_from_the_agent_config: only a JSONtrueunderagentturns it on.test/test_kas_tools_settings.py,test/test_kas_web_fetch_patterns.py,test/test_config_baseline.py,test/test_configuration_doc_defaults.py,test/test_configuration_doc_facts.py(124 passed).Proof: not provable -- other: prove.py reverts the setting reader together with the guard, so the tests error at collection (INCONCLUSIVE rc=21, --per-hunk rc=2); manual mutants instead: guard forced on fails 3 default-path tests, guard forced off fails 3 opt-in tests
Manual verification
N/A — unit coverage sufficient: the change is a translation from a spec dict to KAS rules gated by one config boolean, and a deny over
*is a shape KAS already takes from a.*entry on main.Related Issues
Closes #30167
Part of #33068
Sibling sweep
Swept: git grep -n "converted(" -- src/kiro_crew/acp/kas_permissions.py
Sibling: src/kiro_crew/acp/kas_spec_denies.py -- not affected -- an uncarried deniedCommands entry is already refused at Crew's gate (uncarried_denied_commands)
Sibling: src/kiro_crew/acp/kas_permissions.py -- not affected -- deniedPaths entries travel verbatim as globs; only an entry past the length bound is dropped and named
Pattern harvest
Not generalizable: the other KAS deny translations already refuse or carry each entry; web_fetch.blocked was the last one that dropped a deny silently.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement