Skip to content

fix(docs): add SIWE domain validation to authentication examples#1553

Open
faisalnugroho wants to merge 1 commit into
base:masterfrom
faisalnugroho:fix/siwe-domain-validation
Open

fix(docs): add SIWE domain validation to authentication examples#1553
faisalnugroho wants to merge 1 commit into
base:masterfrom
faisalnugroho:fix/siwe-domain-validation

Conversation

@faisalnugroho
Copy link
Copy Markdown

Summary

Fixes #1502

The backend verification examples in the authentication guide only checked the cryptographic signature but not the SIWE message domain, making them vulnerable to cross-domain replay attacks.

Problem

A valid SIWE signature created for evil.com could be submitted to yourapp.com's /auth/verify endpoint and would pass verification, because verifyMessage only checks the cryptographic signature — not whether the message was intended for this domain.

Changes

Backend (Viem) example:

  • Added parseSiweMessage import from viem/siwe
  • Added domain validation before signature verification

Express server example:

  • Added parseSiweMessage import
  • Added domain validation step before signature verification

Both examples now validate that the SIWE domain matches the expected host, following EIP-4361 requirements.

Fixes base#1502

The backend verification examples only checked the cryptographic
signature but not the SIWE message domain, making them vulnerable
to cross-domain replay attacks.

Changes:
- Backend (Viem) example: Add parseSiweMessage and domain check
- Express server example: Add parseSiweMessage import and domain check
- Both examples now validate that the SIWE domain matches the expected
  host before accepting the signature

This follows EIP-4361 requirements for domain validation.
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/2
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@faisalnugroho
Copy link
Copy Markdown
Author

Hi! I'd love to get this PR reviewed when you have a moment. This PR addresses add SIWE domain validation to authentication examples. Happy to make any adjustments based on your feedback. Let me know if there's anything I can do to help move this forward.

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.

fix(docs): authenticate-users backend example missing domain validation — vulnerable to cross-domain replay attack

2 participants