Skip to content

fix(knowledge): require a direct local request for the native folder picker - #14629

Merged
iamwhatever merged 1 commit into
mainfrom
fix/9358-knowledge-picker-direct-local
Sep 28, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/9358-knowledge-picker-direct-local

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Stop the native macOS folder picker from opening on the gateway operator's screen when a remote user reaches the dashboard through a same-host proxy or tunnel.

The knowledge picker offers a native folder dialog when the gateway runs on macOS and was started local-only. But local_only only says how the gateway was started, not where the request came from. The gateway binds loopback, and remote access is delivered by a same-host tunnel or reverse proxy, so a remote user's request still arrives from 127.0.0.1 with local_only True. The dialog then opens on the operator's machine, not the requester's, and blocks there.

Why it matters

A remote user who clicks the picker hangs a modal on someone else's screen for up to the dialog timeout, and their own request stalls. The same helper guards the project picker in handlers/files.py, so the knowledge picker should match it.

Not a goal

  • No change to the typed-path route the picker falls back to.
  • No new remote-access policy; hosted deployments still enforce read-only server-side.

What changed (motivation → approach → change)

A remote user behind a same-host proxy could trigger the native folder dialog on the gateway operator's screen, because the picker only checked local_only and the macOS binary.

The origin of the request was never checked. A proxied request arrives from a loopback peer but carries a forwarding header; a direct browser does not.

_folder_picker_available in src/kiro_crew/dashboard/handlers/knowledge.py now also requires is_direct_local_request, the same helper the project picker uses. A proxied request fails the gate and the picker is hidden, so the dashboard falls back to the typed-path route. test/test_knowledge_add_source.py covers the new cases.

Backwards compatibility

Compatible: the gate only becomes stricter for proxied requests that should never have reached a host-side dialog; a direct local macOS request is unchanged.

Tests

  • test_unavailable_when_a_proxy_forwarded_the_request — a loopback request with a forwarding header fails the gate.
  • test_unavailable_when_the_peer_is_not_loopback — a non-loopback peer fails the gate.
  • test_the_forwarding_header_is_what_flips_it — two requests differing only by the forwarding header flip the result, so the guard is what decides.
  • The _fake_request fixture now carries remote and headers so the real predicate is exercised rather than a mock of itself.

Manual verification

N/A — unit coverage exercises the real is_direct_local_request predicate across the direct, proxied, and non-loopback cases.

Screenshots / video

Why no screenshot: backend request-origin gate only; no rendered UI change.

Pattern harvest

Not generalizable: this re-applies an existing project pattern -- the direct-local-request gate the sibling project picker already uses in handlers/files.py -- to one more picker that lacked it. There is no new rule to harvest; the sibling was already correct.

Supersedes #9358.

Co-authored-by: leonlaiyc <276034861+leonlaiyc@users.noreply.github.com>

@iamwhatever
iamwhatever requested a review from a team as a code owner September 28, 2026 05:14
@iamwhatever iamwhatever added the drive-to-green PR claimed by drive-to-green pipeline label Sep 28, 2026
@iamwhatever iamwhatever self-assigned this Sep 28, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of f33e2b099353a45cc3855a49e357330c8e283099 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Raw TCP tunnels (ssh -L) add no forwarding header and still pass the gate — confirm that known helper limit is an accepted residual here.

[DESIGN-REVIEWED] f33e2b0

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of f33e2b099353a45cc3855a49e357330c8e283099 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

One counted sibling left unfixed: api_upload (files.py:1320) spawns the native choose-file dialog with no origin gate — same root cause, same operator's screen.

Not justified as shipped

  • Item 1 — symptom-level: point patch of the shared root cause (native dialog spawn ignores request origin). Grep osascript spawn sites: 3 — knowledge picker (gated by this PR), reveal/open (gated at files.py:288), and api_upload at files.py:1320 (POST /api/upload), which checks neither local_only nor is_direct_local_request, so a proxied requester still hangs a 120s Finder dialog on the operator's screen. The harvest claim "the sibling was already correct" counted only the sibling the description named.
    Clears when: api_upload is shown origin-gated at a named line, or a linked issue tracks gating it.

What this change ships

Inventory (2 items) — 1 justified

Intent: stop the knowledge folder picker's native macOS dialog from opening on the operator's screen for proxied/remote requests — a FIX.

  1. Proxied or non-loopback dashboard requests no longer see the native knowledge folder picker; typed-path fallback — symptom-level: 1 counted unfixed sibling (api_upload).
  2. Picker tests now exercise the real origin predicate instead of mocking it — justified.

[FIRST-PRINCIPLES-REVIEWED] f33e2b0

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of f33e2b099353a45cc3855a49e357330c8e283099 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f33e2b0

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

@iamwhatever
iamwhatever force-pushed the fix/9358-knowledge-picker-direct-local branch from d4c5695 to 4c085b7 Compare September 28, 2026 05:22
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in same-dir/import-adjacent files (source_providers.py, security_posture.py and their tests) since this head went green (f171749 -> 037362c); CI re-running. Diff unchanged (the knowledge picker guard and its tests do not touch the moved files).

@iamwhatever
iamwhatever force-pushed the fix/9358-knowledge-picker-direct-local branch from 4c085b7 to 0935479 Compare September 28, 2026 05:28
…picker

local_only describes how the gateway was started, not where the request
came from. A same-host tunnel or reverse proxy delivers a remote user's
request from a loopback peer with local_only still True, so the native
folder dialog would open on the gateway operator's screen. Require a
direct local request too, matching the sibling project picker in
handlers/files.py.

Co-authored-by: leonlaiyc <276034861+leonlaiyc@users.noreply.github.com>
@iamwhatever
iamwhatever force-pushed the fix/9358-knowledge-picker-direct-local branch from 0935479 to f33e2b0 Compare September 28, 2026 05:34
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved ~18 commits in import/same-dir-adjacent files since this head went green (037362c -> 499969c); CI re-running. Diff unchanged (the knowledge picker guard and its test do not touch any of the moved files).

@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 Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f33e2b0

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

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

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 28, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 28, 2026 16:24
@iamwhatever
iamwhatever merged commit a25b321 into main Sep 28, 2026
127 of 152 checks passed
@iamwhatever
iamwhatever deleted the fix/9358-knowledge-picker-direct-local branch September 28, 2026 16:38
@dwu96 dwu96 removed the drive-to-green PR claimed by drive-to-green pipeline label Sep 28, 2026
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 28, 2026
bolichen97 added a commit that referenced this pull request Oct 1, 2026
…release/0.8.0 (#15631)

* fix(security): backport the MCP registry, config seal, cron brace and folder-picker fixes (#14629, #14748, #14486, #15344)

Backport of #14629, #14748, #14486, #15344 to release/0.8.0, cherry-picked in main's merge order.

* fix(knowledge): require a direct local request for the native folder picker (#14629)
  (cherry picked from commit a25b321)
* fix(security): write-protect the kiro-cli MCP registry (#14748)
  (cherry picked from commit d55957e)
* fix(sandbox): mount config.json and config.local.json read-only (#14486)
  (cherry picked from commit 909e0fc)
* fix(cron): scan every nested shell level and resolved assignments for braces (#15344)
  (cherry picked from commit 481476a)

Co-authored-by: Joe Guo <zejiangg@amazon.com>
Co-authored-by: leonlaiyc <276034861+leonlaiyc@users.noreply.github.com>
Co-authored-by: Leon <leon.lai.yc@gmail.com>

* fix(security): backport the apps-tree cron mask, listener-scoped credentials and dev-fleet git hardening (#13273, #13929, #14960, #13348)

Backport of #13273, #13929, #14960, #13348 to release/0.8.0, cherry-picked in main's merge order.

* fix(cron): mask the apps tree from every cron child that runs model-supplied code (#13273)
  (cherry picked from commit 0496784)
* fix(electron): scope the local-token mint to the dialed listener (#13929)
  (cherry picked from commit 497361d)
* fix(instances): pair the internal-API credential read with the dialed listener (#14960)
  (cherry picked from commit 2087cde)
* fix(dev-fleet): harden every git read, and resolve the base branch per repository (#13348)
  (cherry picked from commit 64b0a33)

Co-authored-by: kirocrew-agent <agent@kirocrew.local>
Co-authored-by: wave1 verify <worker@localhost>

---------

Co-authored-by: Joe Guo <zejiang.guo@gmail.com>
Co-authored-by: Joe Guo <zejiangg@amazon.com>
Co-authored-by: leonlaiyc <276034861+leonlaiyc@users.noreply.github.com>
Co-authored-by: Leon <leon.lai.yc@gmail.com>
Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: kirocrew-agent <agent@kirocrew.local>
Co-authored-by: wave1 verify <worker@localhost>
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.

4 participants