Skip to content

fix(web): same-origin check on cookie-authenticated mutations (favorite, vote, rate, review) #101

Closed

Description

@mrgoonie

crossOriginRefusal (apps/web/app/lib/auth/same-origin.ts, added in #96 for api.user-api-keys) should also guard the other cookie-authenticated mutating routes, which currently rely on SameSite=Lax alone:

  • api.skill-favorite.ts
  • api.skill-vote.ts
  • api.skill-rate.ts
  • api.skill-review.ts (action)

Routes that also accept a Bearer API key must apply the check only when the request is authenticated by the session cookie, so CLI/API-key clients (no Origin) keep working. Add a test per route: foreign Origin returns 403, same-origin and header-less requests pass.

Follow-up from the review of #96 (refs #79).

Activity

  1. self-assigned this
    on Oct 19, 2026
  2. added and removed on Oct 19, 2026
  3. mrgoonie commented on Oct 19, 2026

    @mrgoonie
    ContributorAuthor

    Triage: P1 security hardening. These are ambient-cookie mutations behind SameSite=Lax only. Each one reads the body with request.json(), which does not require Content-Type: application/json, so a sibling subdomain can send a no-preflight text/plain POST that the cookie rides along on.

    Findings while scouting:

    • All four listed routes (favorite, vote, rate, review) authenticate with only getSession, so none of them has a Bearer path. The "Session/Key" entries in CLAUDE.md were wrong. The check runs unconditionally there, before the session is read.
    • The same gap exists on other routes, so they are fixed in the same PR:
      • POST /api/skills/register (authenticateRequest falls back to the session). It is checked only when method === "session", so CLI publish with a key is unaffected.
      • Release state, personal-kit writes and publisher provision, all through resolveLimitedActor. They are checked only when there is no Authorization and no X-Admin-Secret, and the refusal is 403 cross_origin.
    • I found the docs drift tracked in docs(api): vote endpoint documented with the wrong request/response shape #102.

    The work is stacked on #96 (branch sx-bugs-47-49-61-79), which introduces same-origin.ts and is not merged yet.


    Generated by Claude Code

  4. added
    donePR opened
    and removed on Oct 19, 2026
  5. added
    shippedMerged/deployed
    and removed
    donePR opened
    on Oct 20, 2026
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