ALPQ

Cross-Device QR Login

DRAFT 0.42026-11-01ALPQ Lab spec · draft for comment

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.

Status: a draft for review, not a standard, not in production yet. Test site: hackthis.alpq.us (test accounts only). Builds on: W3C WebAuthn, RFC 10027 (cross-device flows), the proof-of-possession idea of RFC 9449 (DPoP). Checked against OWASP ASVS 5.0.

1Terms

TermMeaning
DesktopThe browser the user wants to sign in on. It shows the QR code.
PhoneThe device that holds the user's passkey and scans the QR code.
ServerThe relying party (RP). It issues codes, verifies passkeys and creates sessions.
CodeA random, single-use identifier for one sign-in attempt, shown as a QR code.
Match iconA labeled icon (key, heart, house…) shown on the desktop that the user must pick on the phone from four.
Handoff codeA one-time 6-digit code issued after the phone approves. The desktop trades it, signed by its device key, for the session.
Device keyA 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.
ProofA per-request signature by the device key over method, path, time and a nonce.

2Protocol flow

Sequence: desktop asks for a code, phone scans and approves with a passkey, desktop receives a one-time code and trades it for the session once. DesktopServerPhone 1 · /qr/new, signed by the device key 2 · code + match icon (30 s) QR shown; a new one every 10 s 3 · scan → /qr/peek 4 · device, city, distance, 4 icons QR hidden; icon stays, 30 s user checks the warning, taps the icon, approves with Face ID / fingerprint 5 · /login/verify: passkey + icon phone shows the 6-digit code too server: passkey first, then icon; session bound to step 1's key; code issued 6 · /qr/status (polling), signed 7 · approved + 6-digit code (not the session) 8 · /qr/claim: code, signed → session, once code fills in; signs in after 3 s (or Log in)
The phone never carries the session. The desktop that holds the key from step 1 claims it once, with the code; every later request is signed.

3Messages and rules

All endpoints take and return JSON over HTTPS with POST. "Signed" means the request MUST carry a valid proof (section 4).

EndpointSignedCallerDoes
/api/qr/newyesDesktopCreates a code bound to the caller's key thumbprint and location; returns the code ID and match icon
/api/qr/peeknoPhoneReturns the requesting device, approximate city, proximity, age and four different icons (one correct, in random order); marks the code scanned
/api/qr/statusyesDesktopReturns pending, scanned, rejected, expired, or approved plus the 6-digit code. Never returns the session
/api/login/optionsnoPhone or desktopReturns WebAuthn options; MAY limit them to credential IDs known to be on that device
/api/login/verifydesktop onlyPhone or desktopVerifies the passkey; with a code ID and pick, approves the desktop instead and returns the 6-digit code to the phone
/api/qr/claimyesDesktopTrades the code ID and 6-digit code for the session, exactly once
/api/register/options, /verifyverify onlyAnyCreates a discoverable passkey with user verification required
/api/me, /api/logoutyesDesktopUses or ends the session

The server MUST enforce:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. The session MUST be bound to the key thumbprint recorded at /qr/new and handed to that key's holder exactly once.
  6. 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/status MAY 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.
  7. 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.
  8. 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.
  9. WebAuthn challenges MUST be single-use and expire within 5 minutes.
  10. 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.
  11. 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.

WhatCounted perLimit
Any API callIP120 / minute
New passkey ceremoniesIP10 / 10 minutes
Sign-in ceremoniesIP30 / minute
Sign-in attemptsIP · passkey20 / minute · 10 / minute
New QR codesdevice key12 / minute (the page asks for 6)
QR scansIP · code20 / minute · 3 per code
Wrong iconsaccount3 / 15 minutes, then QR approvals pause
Code entriesdevice key · approval10 / 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):

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:

  1. 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.
  2. 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.

ThreatDefense hereRFC 10027ASVS 5.0
Relayed QR (attacker's code shown to the victim)Device, city and distance warning on the phone; icon matching; code hidden once scannedProximity; user education and UX; request bindingV6.6.2
Replay or reuse of a code144-bit random, single-use, 30 s; blocked after a wrong pickShort-lived, one-time codesV6.6.2
Guessing the icon1 in 4 per code; one guess per code; 3 wrong per account pause QR sign-in; rate limitsRate limitsV6.6.3
Burning someone's codePasskey checked before the iconV6.3.1
Guessing or stealing the handoff codeUseless without the desktop's device key; 6 digits, 3 tries, 60 s, single-useSender-constrained tokensV6.6.2, V6.6.3
Stolen session tokenBound to a non-exportable key; every request signedSender-constrained tokensV7
Replayed signed requestNonce stored and refused on repeat; 60 s windowV7
Phishing the passkey itselfWebAuthn binds the assertion to the real origin; user verification requiredV6
Lost or stolen phoneApproval needs the phone's biometric or passcode; the passkey can be removedTrusted devicesV7.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

9Known gaps and questions

Left open on purpose for reviewers to probe:

  1. /api/qr/peek needs no authentication: anyone holding a code sees the requesting device, city and four icons, though they can't approve it.
  2. Rate limits trust the CDN's viewer address. Offices and carrier networks share one IP budget.
  3. No refresh-token rotation; sessions simply expire after 1 hour.
  4. No account recovery or passkey management screens.
  5. 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:

10Changes

VersionDateChange
0.42026-11-01Rules 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.32026-10-27Icons 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.22026-10-27Rate limits; passkey verified before the number; 3 wrong numbers pause QR sign-in; proximity warning. Closes gaps 2–4 of 0.1.
0.12026-10-27First draft; test site live.

11References