Skip to content

fix(web): same-origin check on cookie-authenticated kit and collection writes #113

Closed

Description

@mrgoonie

Follow-up to #101, which covered favorite/vote/rate/review. The personal kit (kit-http.ts) and collection (collection-http.ts) write paths accept session cookies without crossOriginRefusal (apps/web/app/lib/auth/same-origin.ts). They are currently shielded by the mandatory Content-Type: application/json (and preflight for PATCH/DELETE), so this is defence in depth, not an open hole. Apply the check only when the request is authenticated by the session cookie, so API-key clients keep working; add a test per route group: a foreign Origin returns 403, while same-origin and header-less requests pass. Found during review of #112.

Activity

  1. self-assigned this
    on Oct 29, 2026
  2. added
    donePR opened
    and removed on Oct 29, 2026
  3. added
    shippedMerged/deployed
    and removed
    donePR opened
    on Oct 29, 2026
  4. mrgoonie commented on Oct 29, 2026

    @mrgoonie
    ContributorAuthor

    Shipped in #159 (squash 25dabca on main).

    The production check had already landed in #103: resolveLimitedScopedActor refuses a foreign Origin on the session-cookie path, and every kit and collection write goes through it. #159 adds the requested tests per route group:

    • A foreign Origin, a sibling subdomain or Sec-Fetch-Site: same-site gets 403 cross_origin on every collection write sub-route and every kit write sub-route, and nothing is written.
    • Same-origin, header-less and API-key writes pass.

    Evidence:

    • Full vitest suite: 2687 passed. Typecheck clean.
    • CI web-contracts-cli is green.
    • An isolated review mutation-tested the new tests: they fail when the check is removed.

    Generated by Claude Code

  5. added a commit that references this issue on Oct 30, 2026
    25dabca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-handleFound during automated runshippedMerged/deployed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions