Skip to content

Echo the companion state nonce through the authorize flow - #169

Merged
pratikbodkhe merged 1 commit into
mainfrom
feat/companion-state-echo
Jul 19, 2026
Merged

Echo the companion state nonce through the authorize flow#169
pratikbodkhe merged 1 commit into
mainfrom
feat/companion-state-echo

Conversation

@pratikbodkhe

Copy link
Copy Markdown
Contributor

The desktop companion sends an anti-CSRF state nonce when opening /companion/authorize, but the minutia://auth-callback deep link dropped it, so the desktop must accept state-less callbacks. This threads state from the incoming query through to the callback URL.

  • Encoded exactly once via encodeURIComponent; hostile characters (&, =, #, spaces) cannot smuggle params or break the URL.
  • Omitted entirely when absent: older companion builds get a byte-identical callback.
  • Signed-out flows carry state opaquely inside the existing next param (middleware, login, /auth/callback untouched).
  • Coverage: unit (exact-string, encoding, absent/null/empty, safeAuthNextPath passthrough) and the companion-handshake e2e now asserts the nonce end-to-end on both the signed-in and login-redirect paths.

Unblocks the companion dropping nil-state acceptance in a follow-up desktop release. Two independent reviews (spec + security): no findings.

The desktop companion opens /companion/authorize with an anti-CSRF state
nonce, but the minutia:// callback dropped it, forcing the client to
accept state-less callbacks. The authorize client now threads state from
the incoming query through to the deep link (percent-encoded exactly
once, omitted entirely when absent so older companion builds see a
byte-identical URL). State survives the signed-out login round-trip by
riding the existing next param; covered at unit and e2e level, including
hostile-character encoding and safeAuthNextPath passthrough.
@pratikbodkhe
pratikbodkhe merged commit 922039b into main Jul 19, 2026
18 checks passed
@pratikbodkhe
pratikbodkhe deleted the feat/companion-state-echo branch July 19, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant