Files
Dylan M. Taylor 4c9f1b98f5 fix: refuse to show desktop-login approval inside a frame (#266)
## What was wrong

The desktop-login consent page (`/login/desktop`,
`DesktopLoginApproval`) could be rendered inside a cross-origin frame.
The webapp's `netlify.toml` sends no `frame-ancestors` or
`X-Frame-Options` for it, and the component did not check for framing.
An attacker can start a login challenge for their own desktop, embed the
verification URL in a page they control, hide the frame under decoy
content, and steer the signed-in victim's click onto "Approve desktop
login". The backend then issues the victim's session to the attacker's
device-token holder (clickjacking, CWE-1021).

## What changed

- `apps/artcraft-webapp/netlify.toml`: `/login/desktop` and
`/login/desktop/*` are served with `Content-Security-Policy:
frame-ancestors 'none'` and `X-Frame-Options: DENY`. This is scoped to
the approval route so other webapp pages are unaffected.
- `libs/login/.../desktop-login-approval.tsx`: if `window.self !==
window.top` (or that check throws), the component renders "Open this
login link directly in your browser to approve it." It does not fetch
the review and `decide` is a no-op. This covers deployments that do not
send the headers.
- New webapp test: a framed render shows no Approve button and makes no
API call.

## Blast radius

Only the desktop-login approval route. Opening the link top-level
(browser, QR code) behaves as before. Any legitimate flow that frames
`/login/desktop` would stop working; none exists in this repo.

## Checks run

- `NODE_OPTIONS=--no-experimental-webstorage npx vitest run --root
apps/artcraft-webapp src/pages/login`: 20/20 pass, including the new
framed case. Under Node 26 the flag is needed, or jsdom's
`sessionStorage` is shadowed and every test in this file fails, before
and after this change.
- `npx vitest run --root libs/login`: pass.
- `netlify.toml` parses as TOML.

## Checks not run

- `tsc -p libs/login/tsconfig.lib.json`: only the pre-existing TS6305
errors for the unbuilt `@storyteller/api` `dist`.
- Netlify deploy preview header verification.

Addresses CodeRabbit security findings (CWE-1021).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Desktop login approval pages displayed inside a frame now instruct
visitors to open the link directly in a browser. The page does not load
or submit a login challenge, or offer approval or decline actions.
* Browser security headers prevent desktop login pages from being
displayed within frames, including when framed pages involve
cross-origin access.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-11 12:11:01 -05:00
..
2026-09-11 01:03:53 -04:00
2026-09-01 10:45:02 -04:00
2026-09-18 14:12:34 -04:00
2026-09-11 01:03:53 -04:00
2026-09-11 01:03:53 -04:00