Repository navigation
fix: accept ip literal domain in Siwe messages - #696
Open
gomesalexandre wants to merge 1 commit into
Open
gomesalexandre wants to merge 1 commit into
gomesalexandre wants to merge 1 commit into
Conversation
EIP-4361 defines `domain` as an RFC 3986 authority, so a dapp served
from `http://[::1]:3000` has domain `[::1]:3000`. `createMessage` only
allowed DNS names, IPv4 and localhost and threw on it, and `parseMessage`
returned `{}` for the message. The `domain ipv6` case of the official
spruceid/siwe `parsing_positive.json` vectors fails this way.
Userinfo authorities are left out on purpose: page origins never carry
userinfo, and `a.com@b.com wants you to sign in` only helps phishing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@gomesalexandre is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
EIP-4361 defines
domain = authority(RFC 3986), so a dapp served fromhttp://[::1]:3000signs in with domain[::1]:3000.Siwe.createMessageonly accepts DNS names, IPv4 andlocalhostand throws on it, andSiwe.parseMessagereturns{}for the resulting message becauseprefixRegexcan't match[/]:I found this by running the official spruceid/siwe vectors (https://github.com/spruceid/siwe/tree/main/test) against
Siwe: thedomain ipv6case inparsing_positive.jsonfails on main for both parse and create.The change:
createMessagealso accepts[literal]with an optional port. The literal can't contain whitespace and is checked by the existingisAuthority, which is whatisUrialready uses for IPv6 and IPvFuture hosts, so[zzz],[::1,[::300.0.0.0]and[::\t1]still throw.prefixRegexgets a bracketed alternative for the domain group, soparseMessagereads the domain back. It is as lenient as the existing domain group: parse doesn't validate the domain,createMessagedoes, andvalidateMessagecompares it exactly. A 100k-char[input still parses in under a millisecond. I dropped theregexr.com/80gdjlink above it because it pointed at the old regex.I left userinfo authorities (
test@127.0.0.1, also in the vectors) out on purpose. A page origin never carries userinfo, solegit.com@attacker.com wants you to sign inhas no real producer and only helps phishing.Tests: valid
[::cafe],[::1]:3000,[2001:db8::1]:443,[v1.fe]and invalid[::1,[zzz],[::300.0.0.0],[::1]:123456,user@[::1],[::\t1]domains increateMessage, plus a parse -> create round trip of the vector message. The valid cases fail on main.🤖 Generated with Claude Code