fix: enforce SIWS domain check in requireTeamMemberOrAdmin#86
Merged
Conversation
requireAdmin and requireOwnWallet verify the sign-in message domain against EXPECTED_DOMAIN (skippable via DISABLE_SIWS_DOMAIN_CHECK); requireTeamMemberOrAdmin skipped it entirely. Enable it there too so all three middleware are consistent — preview/staging origins are handled by DISABLE_SIWS_DOMAIN_CHECK, not by omitting the check. Adds a domain-mismatch test. Server: 162 tests pass.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security hardening.
requireAdminandrequireOwnWalletverify the sign-in messagedomainagainstEXPECTED_DOMAIN(skippable viaDISABLE_SIWS_DOMAIN_CHECK), butrequireTeamMemberOrAdminskipped that check entirely — a sign-in message produced for a different origin would still be accepted on team-gated routes.This enables the same check there, so all three middleware are consistent. Preview/staging origins are handled the intended way —
DISABLE_SIWS_DOMAIN_CHECK=true— rather than by omitting the check.Addresses the backlog item "
requireTeamMemberOrAdminmissing SIWS domain check" (docs/improvement-backlog.md, 2026-04-23).Changes
server/api/middleware/auth.middleware.js—requireTeamMemberOrAdmincallsauthenticateRequest(..., { checkDomain: true }).auth.middleware.test.js— adds a 403-on-domain-mismatch test forrequireTeamMemberOrAdmin.Test plan
cd server && npm test— 162 tests pass (21 files), including the new domain-mismatch case; all existingrequireTeamMemberOrAdmincases (which sign onlocalhost) still pass.Note
Live deployments must have
EXPECTED_DOMAINset correctly (orDISABLE_SIWS_DOMAIN_CHECK=truefor previews) — same requirement the other two middleware already had.🤖 Generated with Claude Code