Skip to content

fix(example): require SIWE domain bind in iron-session verify - #2690

Open
SashaMIT wants to merge 1 commit into
rainbow-me:mainfrom
SashaMIT:fix/siwe-iron-session-require-domain
Open

fix(example): require SIWE domain bind in iron-session verify#2690
SashaMIT wants to merge 1 commit into
rainbow-me:mainfrom
SashaMIT:fix/siwe-iron-session-require-domain

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • The with-next-siwe-iron-session example verified signature + session nonce but never bound siweMessage.domain to the app host.
  • The sibling with-next-siwe-next-auth example already rejects domain mismatch.
  • Without domain binding, a SIWE signature minted for an attacker-controlled domain can be replayed against /api/verify under a matching nonce (cross-site login as the victim address).
  • Also check nonce before verifyMessage (cheap reject first).

Test plan

  • Manual: start iron-session example, confirm valid SIWE still logs in
  • Manual: POST verify with a message whose domain differs from Host → 422 Invalid domain

Made with Cursor

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
SashaMIT requested a review from a team as a code owner August 8, 2026 15:24
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@SashaMIT is attempting to deploy a commit to the rainbowdotme Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e901a4d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +19 to +20
const expectedHost = req.headers.host;
if (!expectedHost || siweMessage.domain !== expectedHost) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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