Repository navigation
refactor(apps): share the proxy's hop-by-hop list with app web origins - #38846
Open
LachlanLindsay wants to merge 1 commit into
Open
LachlanLindsay wants to merge 1 commit into
LachlanLindsay wants to merge 1 commit into
Conversation
LachlanLindsay
requested review from
a team and
KiroCrewCaptain
as code owners
November 17, 2026 23:53
The app web origin's response drop list restated the API proxy's hop-by-hop headers instead of reading them, so a name the proxy learns to drop would still reach the browser from an app origin. It now reads _PROXY_HOP_HEADERS through the routes facade, as the request side already does, plus the two hop-by-hop spellings that list lacks and Clear-Site-Data. Proxy-Authorization, which the copy missed, is now dropped from responses as well. The spec said a host-only cookie keeps one app's cookie from reaching another app's name. It stops a backend's response doing that, but a script on one app's pages can set a cookie for apps.localhost, which the browser sends to every app origin and the gateway forwards, and a Clear-Site-Data "cookies" from one app origin clears every app's cookies. The spec, the manifest reference and the module docstring say so, and tell an app to trust a cookie by a value it issued, never by its name. Refs kirodotdev#36965
LachlanLindsay
force-pushed
the
refactor/app-web-origin-followup
branch
from
November 18, 2026 01:36
52e7e68 to
b4ed48e
Compare
Contributor
Author
|
Rebased: main moved in |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Motivation
Goal: App authors learn from the docs that another app's pages can set and clear their app's cookies, and an app web origin drops every hop-by-hop response header the API proxy drops.
#36967 merged with three points left for a follow-up: the Design Review's doc notes, the cookie wording in the app web origin spec, and the response-header list. #37670 covered the doc notes ("own origin", the
no-corsprobe, CSRF andAuthorization). Two points remain:apps.localhost, which the browser sends to every app origin and the gateway forwards. AClear-Site-Data: "cookies"from one app origin clears every app's cookies._DROP_RESPONSE_HEADERSinapps/app_web_origin.pyrestates the API proxy's hop-by-hop list instead of reading it. The copy has already drifted: it missesProxy-Authorization.Why it matters
The docs are what an app author builds against. An app that trusts a session cookie by its name can be handed one by another app's page, and the spec's wording invites exactly that. The second copy of the hop-by-hop list is the shape the First Principles review blocked on the request side of #36967: a name the proxy learns to drop is still relayed here.
Not a goal
apps.localhost, and no response header changes what a page's own script can set.What changed (motivation → approach → change)
App authors learn that another app's pages can set and clear their app's cookies, so their app trusts a cookie by a value it issued, never by its name. In code, the app origin reads the API proxy's hop-by-hop list instead of keeping its own copy; the one header that adds,
Proxy-Authorization, is a request header no browser reads in a response.SameSiteand CSRF onlyapps.localhost, andClear-Site-Data: "cookies"clears every app's cookies, so an app trusts a cookie by a value it issued, never by its namebackend.webOriginSameSiteand CSRF onlyapps/app_web_origin.py)Proxy-Authorization_drop_response_headers(): the proxy's_PROXY_HOP_HEADERS, read through the routes facade, plusProxy-Connection,TrailerandClear-Site-DataThe list is read lazily through the facade for the same reason as
_drop_request_headers(): the dashboard imports this module on its first response. The module docstring and the comment onClear-Site-Datasay why it is dropped: a browser applies"cookies"to the whole site, which every app origin shares.Backwards compatibility
Compatible: every header the old list dropped is still dropped. The one addition,
Proxy-Authorization, is a request header that no browser reads in a response.Removes nothing:
_DROP_RESPONSE_HEADERSwas private to the module with no reader insrc/,test/orwebsite/src/, and_drop_response_headers()returns a superset of it.Tests
test_every_hop_by_hop_header_the_api_proxy_drops_is_dropped_from_responses:_PROXY_HOP_HEADERSmust be a subset of_drop_response_headers(), and every one of those names plusProxy-ConnectionandTrailersent throughhardened_response_headersmust leave only the gateway's CSP. With main's list in its place, it fails onproxy-authorization.-n0, then 10 at-n 4 --dist loadgroup --max-worker-restart=2withtest/test_routes_facade.pyandtest/test_dashboard_security_headers.pyas co-tenants, all green.test/test_app_web_origin.pyin a shuffled order (seed 23376): 73 passed.scripts/run_scoped_tests.py, 15 files): 411 passed, 2 skipped. The flake-pattern ratchet: 71 passed. semgrep on the diff: 0 findings.Gate proof: tree 0782e4f67533; ran 25; skipped mypy=other:this venv lacks the types-requests stub and has an older aiohttp; all 6 errors are in 4 files this diff does not touch, and mypy on src/kiro_crew/apps/app_web_origin.py passes
Manual verification
The two cookie claims were checked in headless Chromium 155, with one loopback server answering for
alpha.apps.localhostandbeta.apps.localhost:planted=from-alpha; domain=apps.localhost. beta received it,localhostdid not, and a POST from alpha's page to beta carried both it and beta's ownSameSite=Strictcookie.Clear-Site-Data: "cookies"response from alpha cleared alpha's and beta's host-only cookies, and left the cookie onlocalhost.Related Issues
Refs #36965
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)