fix(example): require SIWE domain bind in iron-session verify - #2690
fix(example): require SIWE domain bind in iron-session verify#2690SashaMIT wants to merge 1 commit into
Conversation
The with-next-siwe-iron-session example verified signature + nonce but never checked siweMessage.domain against the app host (unlike the next-auth example), enabling cross-site SIWE login replay. Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
|
@SashaMIT is attempting to deploy a commit to the rainbowdotme Team on Vercel. A member of the Team first needs to authorize it. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e901a4dcd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const expectedHost = req.headers.host; | ||
| if (!expectedHost || siweMessage.domain !== expectedHost) { |
There was a problem hiding this comment.
Bind SIWE messages to a trusted configured host
In self-hosted deployments where the proxy does not enforce a host allowlist, req.headers.host is supplied by the client and therefore cannot establish the application's identity. An attacker can request a nonce and retain the iron-session cookie while sending Host: attacker.example, have a victim sign that nonce for attacker.example, and submit the signature with the same spoofed header, so this check still accepts the cross-domain replay it intends to prevent. Compare against a configured public origin or an explicit trusted-host allowlist instead.
Useful? React with 👍 / 👎.
Summary
with-next-siwe-iron-sessionexample verified signature + session nonce but never boundsiweMessage.domainto the app host.with-next-siwe-next-authexample already rejects domain mismatch./api/verifyunder a matching nonce (cross-site login as the victim address).verifyMessage(cheap reject first).Test plan
domaindiffers fromHost→ 422 Invalid domainMade with Cursor