Cross-Device QR Login
Written for GOVW's own use and published openly: take what's useful, and tell us what's wrong.
A user signs in on a desktop browser by scanning a short-lived QR code with a phone that holds a passkey. The user taps the matching icon and approves with Face ID, a fingerprint or the phone's passcode. A one-time 6-digit code then fills in on the desktop, which signs in. The desktop session is bound to a key that browser can't export, so a copied session token is useless on its own.
1Terms
| Term | Meaning |
|---|---|
| Desktop | The browser the user wants to sign in on. It shows the QR code. |
| Phone | The device that holds the user's passkey and scans the QR code. |
| Server | The relying party (RP). It issues codes, verifies passkeys and creates sessions. |
| Code | A random, single-use identifier for one sign-in attempt, shown as a QR code. |
| Match icon | A labeled icon (key, heart, house…) shown on the desktop that the user must pick on the phone from four. |
| Handoff code | A one-time 6-digit code issued after the phone approves. The desktop trades it, signed by its device key, for the session. |
| Device key | A P-256 key pair created by the desktop browser with a private key that can't be extracted. |
| Key thumbprint (jkt) | The RFC 7638 SHA-256 thumbprint of the device key's public JWK. |
| Proof | A per-request signature by the device key over method, path, time and a nonce. |
2Protocol flow
3Messages and rules
All endpoints take and return JSON over HTTPS with POST. "Signed" means the request MUST carry a valid proof (section 4).
| Endpoint | Signed | Caller | Does |
|---|---|---|---|
/api/qr/new | yes | Desktop | Creates a code bound to the caller's key thumbprint and location; returns the code ID and match icon |
/api/qr/peek | no | Phone | Returns the requesting device, approximate city, proximity, age and four different icons (one correct, in random order); marks the code scanned |
/api/qr/status | yes | Desktop | Returns pending, scanned, rejected, expired, or approved plus the 6-digit code. Never returns the session |
/api/login/options | no | Phone or desktop | Returns WebAuthn options; MAY limit them to credential IDs known to be on that device |
/api/login/verify | desktop only | Phone or desktop | Verifies the passkey; with a code ID and pick, approves the desktop instead and returns the 6-digit code to the phone |
/api/qr/claim | yes | Desktop | Trades the code ID and 6-digit code for the session, exactly once |
/api/register/options, /verify | verify only | Any | Creates a discoverable passkey with user verification required |
/api/me, /api/logout | yes | Desktop | Uses or ends the session |
The server MUST enforce:
- A code MUST hold at least 128 bits of randomness, be single-use, and expire within 30 seconds. The desktop SHOULD show a new code every 10 seconds.
- Once a code is scanned, the desktop MUST hide it and SHOULD keep showing the match icon, with its label, and a countdown. The code expires 30 seconds after the scan.
- The phone's passkey assertion, with user verification, MUST be verified before the match icon is checked. A stranger holding a code can't burn it.
- A wrong pick MUST block the code. Three wrong picks for one account within 15 minutes MUST pause QR approvals for that account until the window ends.
- The session MUST be bound to the key thumbprint recorded at
/qr/newand handed to that key's holder exactly once. - After approval the server MUST issue a random 6-digit handoff code, valid for 60 seconds and only for the key from
/qr/new./qr/statusMAY return the code; only/qr/claim, signed by that key, returns the session. Three wrong codes MUST cancel the approval. The server SHOULD compare codes in constant time. - The desktop SHOULD fill in the code by itself and sign in after a short visible countdown (3 seconds here) that the user can cancel. The phone SHOULD show the same code so the user can type it if filling in fails.
- Icons MUST differ in shape, not only color, and each MUST carry a text label for screen readers. Icons that read as yes or no (checks, crosses) SHOULD NOT be used.
- WebAuthn challenges MUST be single-use and expire within 5 minutes.
- Every QR MUST have readable text beside it. The desktop MUST show where the code leads (the site's domain and a short path) so people can check it before scanning, and MUST offer a way in for people who can't scan, such as signing in with a passkey on the desktop itself. The full code isn't meant to be typed, since it lasts 30 seconds.
- A link that moves a session to another device (for example "continue on your phone") MUST work for that one session only and expire with it. It MUST be shown as text the user can type or tap, next to the QR.
4Device-bound requests
The desktop browser creates one ECDSA P-256 key pair with WebCrypto, extractable: false, kept in IndexedDB. Every signed request carries two headers:
X-ALPQ-Key: base64url( JSON public JWK {kty, crv, x, y} )
X-ALPQ-Proof: <unix seconds>.<nonce>.<base64url ECDSA P-256/SHA-256 signature>
signed string: "<METHOD> <path> <unix seconds> <nonce>"
The server MUST reject a key that isn't a public P-256 key or that carries a private part (d); reject a proof more than 60 seconds from server time; verify the signature, then store the nonce for at least twice the window and reject any repeat; and compare the RFC 7638 thumbprint with the one bound to the code or session.
This follows the idea of DPoP (RFC 9449) without the JWT format. Moving to standard DPoP proofs, or to Device Bound Session Credentials once browsers ship it widely, is an open question.
5Rate limits
Fixed windows, counted on the server. Over a limit the server answers 429 with a Retry-After header. The client IP is the CDN's viewer address, not a request header the client can set.
| What | Counted per | Limit |
|---|---|---|
| Any API call | IP | 120 / minute |
| New passkey ceremonies | IP | 10 / 10 minutes |
| Sign-in ceremonies | IP | 30 / minute |
| Sign-in attempts | IP · passkey | 20 / minute · 10 / minute |
| New QR codes | device key | 12 / minute (the page asks for 6) |
| QR scans | IP · code | 20 / minute · 3 per code |
| Wrong icons | account | 3 / 15 minutes, then QR approvals pause |
| Code entries | device key · approval | 10 / minute · 3 wrong, then the approval is canceled |
6Proximity
The main attack on QR sign-in is relaying: someone far away shows you a real code from their own session. RFC 10027 lists proximity checks as a mitigation. This draft compares rough, IP-based locations of the desktop (at /qr/new) and the phone (at /qr/peek):
- Far (more than 300 km apart, or different countries): the phone MUST show a warning naming both places, such as "This sign-in is from Miami (about 4,219 km away). You're in Lima. Don't approve unless that's you."
- Near: the phone MAY show a confirmation.
- Unknown: no claim is shown.
IP location is a hint, not proof: VPNs, carrier networks and travel all move it. A warning never blocks; the user decides. Two stronger signals are planned:
- Timing. Light in fiber covers about 200 km per millisecond. If a browser's round trip to a nearby edge is 20 ms, it can't be more than about 2,000 km from that edge, whatever an IP lookup says.
- Phone location, opt-in. With permission, the phone's own position compared with the desktop's area.
7Security considerations
RFC 10027 asks implementers to assess risk and combine mitigations. This design combines the following.
| Threat | Defense here | RFC 10027 | ASVS 5.0 |
|---|---|---|---|
| Relayed QR (attacker's code shown to the victim) | Device, city and distance warning on the phone; icon matching; code hidden once scanned | Proximity; user education and UX; request binding | V6.6.2 |
| Replay or reuse of a code | 144-bit random, single-use, 30 s; blocked after a wrong pick | Short-lived, one-time codes | V6.6.2 |
| Guessing the icon | 1 in 4 per code; one guess per code; 3 wrong per account pause QR sign-in; rate limits | Rate limits | V6.6.3 |
| Burning someone's code | Passkey checked before the icon | V6.3.1 | |
| Guessing or stealing the handoff code | Useless without the desktop's device key; 6 digits, 3 tries, 60 s, single-use | Sender-constrained tokens | V6.6.2, V6.6.3 |
| Stolen session token | Bound to a non-exportable key; every request signed | Sender-constrained tokens | V7 |
| Replayed signed request | Nonce stored and refused on repeat; 60 s window | V7 | |
| Phishing the passkey itself | WebAuthn binds the assertion to the real origin; user verification required | V6 | |
| Lost or stolen phone | Approval needs the phone's biometric or passcode; the passkey can be removed | Trusted devices | V7.5 |
At this draft, sessions last 1 hour with no refresh, and there's no account recovery flow. Both are deliberate for the test site.
8Privacy
- Biometrics stay on the phone. Face ID or a fingerprint only unlocks the passkey locally. The server never receives biometric data.
- What the server stores: username, the passkey's public key and counter, and short-lived records for codes, challenges, nonces, sessions and rate-limit counters. Expired records are deleted automatically.
- Location: rough city and coordinates come from the network address via the CDN, are shown on the phone once, and are deleted with the code (30 seconds).
- No tracking: no third-party scripts, cookies or analytics on the sign-in page.
9Known gaps and questions
Left open on purpose for reviewers to probe:
/api/qr/peekneeds no authentication: anyone holding a code sees the requesting device, city and four icons, though they can't approve it.- Rate limits trust the CDN's viewer address. Offices and carrier networks share one IP budget.
- No refresh-token rotation; sessions simply expire after 1 hour.
- No account recovery or passkey management screens.
- Rate limits use fixed windows, so up to twice a limit can land around a window boundary (for example 2 wrong icons just before it and 3 just after). A sliding window would close that.
Questions for reviewers:
- Is picking 1 of 4 icons enough, or should the desktop show a second icon for the user to tap there (a two-way match)? It would cut blind guesses from 1 in 4 to about 1 in 40, but it doesn't stop a live relay, so this draft leaves it out.
- The handoff code mostly makes a familiar step visible; the device key does the real binding. Is that worth the extra step, or should the code appear only when filling in fails?
- Should the proof move to standard DPoP JWTs, or wait for Device Bound Session Credentials?
- Is a 30-second window after scanning the right balance between ease of use and exposure?
- Is 300 km a sensible distance for the warning? Should a far result ever block instead of warn?
10Changes
| Version | Date | Change |
|---|---|---|
| 0.4 | 2026-11-01 | Rules 10 and 11: readable text beside every QR, a way in for people who can't scan, and hand-off links that work for one session only. Inspired by an identity check seen in the wild. |
| 0.3 | 2026-10-27 | Icons replace numbers (4 to pick from, labeled); one-time 6-digit handoff code with automatic fill-in, 3-second countdown and manual entry; new /api/qr/claim; /qr/status no longer returns the session. |
| 0.2 | 2026-10-27 | Rate limits; passkey verified before the number; 3 wrong numbers pause QR sign-in; proximity warning. Closes gaps 2–4 of 0.1. |
| 0.1 | 2026-10-27 | First draft; test site live. |
11References
- RFC 10027: Cross-Device Flows: Security Best Current Practice (Kasselman, Fett, Skokan)
- OWASP Application Security Verification Standard (ASVS) 5.0
- W3C Web Authentication (WebAuthn)
- RFC 9449: OAuth 2.0 Demonstrating Proof of Possession (DPoP) · RFC 7638: JWK Thumbprint
- Libraries in the test site: SimpleWebAuthn 13.3.0 (MIT), qrcode-generator 2.0.4 (MIT)