Repository navigation
fix: validate the authority of Siwe.isUri URIs that have a path - #695
Open
gomesalexandre wants to merge 1 commit into
Open
gomesalexandre wants to merge 1 commit into
gomesalexandre wants to merge 1 commit into
Conversation
`isUri` only ran `isAuthority` when the path was empty, so an authority it rejects on its own (`uri://[::300.0.0.0]`, `https://example.com:bad`) was accepted as soon as a path followed it, and `createMessage` emitted such URIs. Two cases in the official spruceid/siwe `invalid_uris.json` vectors fail this way. 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.
Siwe.isUrionly checks the authority when the path is empty, so an authority it rejects on its own gets through as soon as a path follows it:createMessagerunsisUrionuriand on every resource, so on main it emits a message withURI: uri://[::300.0.0.0]/p/path, while the same URI without the path throwsInvalidMessageFieldError.I found this by running the official spruceid/siwe test vectors (https://github.com/spruceid/siwe/tree/main/test) against
Siwe. Two cases ininvalid_uris.jsonfail on main (IPv4 bad octets: uri://[::0.0.0.256]/p/pathanduri://[::300.0.0.0]/p/path), and the same two fail ininvalid_resources.json. With this change all 17 + 16 pass.valid_uris.jsonstays at 34 of 36 before and after: the two that fail areuri://[::000.000.010.001]anduri://[::001.099.200.255], which have leading zeros in the embedded IPv4. RFC 3986'sdec-octetdoesn't allow those, so ox is right to reject them.The
path.length === 0guard came from #434 (mine), which addedisAuthorityonly for the empty-path case it newly allowed. The path does not change what a valid authority is:splitUrialready cuts the authority at the first/,?or#. So the fix drops the guard, andisAuthoritynow runs whenever there is an authority. Everything that becomes rejected with a path was already rejected without one (a@b@c,h:80:90,[],[::1]x). That includes IPv6 zone ids like[fe80::1%25eth0], which RFC 3986 doesn't have (they come from RFC 6874).Tests: invalid authorities with a path (the two vector URIs,
https://example.com:bad/login,https://[:::]/login,https://[::1/login) and valid ones with a path (IPv6, userinfo + port, IPvFuture). The invalid cases fail on main.🤖 Generated with Claude Code