Repository navigation
fix(Siwe): tighten scheme, statement, and IP literal domain validation - #705
Merged
Merged
Conversation
Rejects a comma in `scheme`, rejects `\r`, U+2028 and U+2029 in `statement`, and accepts IP literal `domain` values without letting a userinfo authority such as `[evil.com@[::1]` through. Supersedes #696, #698, and #699. Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5cc-eb3a-72b3-bdda-0480feddb7f9 Co-authored-by: jxom <jake@tempo.xyz>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 19, 2026
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
Published pnpm add ox@pr-705
pnpm add ox@0.0.0-pr-705-80931b8 |
jxom
added a commit
that referenced
this pull request
Nov 19, 2026
* fix: hash zero-valued leaves in `BinaryStateTree.merkelize` (#690) EIP-7864 only maps the 64-byte zero input to the zero hash, so a leaf set to 32 zero bytes is a real leaf. `hash` zeroed any all-zero input, which merkelized zero-valued leaves as empty (a lone zero leaf at the zero key gave the empty-tree root). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5cc-eb3a-72b3-bdda-0480feddb7f9 Co-authored-by: jxom <jake@tempo.xyz> * fix: encode legacy `v` above 255 in `Transaction.toRpc` (#691) `Transaction.toRpc` encoded `v` with `size: 1` for every transaction type. A legacy EIP-155 `v` is `chainId * 2 + 35 + yParity`, so from chain ID 110 on (Polygon, Base, Arbitrum, ...) it passes 255 and `toRpc` threw `Hex.IntegerOutOfRangeError`. `toRpc(fromRpc(tx))` failed on real legacy transactions from those chains. execution-apis types the legacy `v` as `uint` and the typed `v` as `byte`, so legacy now encodes it without a size and typed transactions keep the single byte. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 6b94083) Co-authored-by: jxom <jake@tempo.xyz> * fix: encode authorization `r` and `s` as quantities in `Authorization.toRpc` (#693) execution-apis types authorization list `r` and `s` as `uint256`, so nodes expect them without leading zeros. `Authorization.toRpc` passed the 32-byte padded values through, and geth-based nodes reject them in `eth_estimateGas`, `eth_call` and `eth_sendTransaction` ("hex number with leading zero digits") whenever the top nibble is zero. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d7b57e1) Co-authored-by: jxom <jake@tempo.xyz> * fix: keep `requestsHash` in `Block.toRpc` (#703) Supersedes #692. Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5cc-eb3a-72b3-bdda-0480feddb7f9 Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com> Co-authored-by: jxom <jake@tempo.xyz> (cherry picked from commit b31cd5d) * fix: encode `BlockOverrides` `prevRandao` as a 32-byte hash (#704) Supersedes #700. Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5cc-eb3a-72b3-bdda-0480feddb7f9 Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Martina <261225237+Iamsohungrynow@users.noreply.github.com> Co-authored-by: jxom <jake@tempo.xyz> (cherry picked from commit 9c3280b) * fix(0.x): reject a comma in `Siwe` `scheme` and every line break in `statement` Ports the scheme and statement parts of #705 (from #698 and #699). The IP literal domain part does not apply to 0.x. Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5cc-eb3a-72b3-bdda-0480feddb7f9 Co-authored-by: jxom <jake@tempo.xyz> * docs: fix stated outputs in hash and selector examples (#702) (cherry picked from commit 2d43a3a) Co-authored-by: jxom <jake@tempo.xyz> --------- Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: jxom <jake@tempo.xyz> Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Martina <261225237+Iamsohungrynow@users.noreply.github.com>
Merged
jxom
added a commit
that referenced
this pull request
Nov 19, 2026
…l domains (#705) (#709) * fix(siwe): isUri rejects authority-only URIs with an empty path (#434) * fix(siwe): isUri rejects authority-only URIs with an empty path Siwe.isUri required scheme?.length && path && path.length >= 0 - the `path &&` guard short-circuited before the tautological length check ever ran, so any URI with an empty path (e.g. a bare origin like https://example.com) was rejected. The comment directly above states the opposite intent: "scheme and path are required, though the path can be empty". Per RFC 3986 an authority-only URI legitimately has an empty path component, and this is also the single most common SIWE uri value - Siwe.createMessage threw for https://login.xyz, the EIP-4361 reference example, and for any pathless entry in resources. viem's identical sibling function (utils/siwe/utils.ts) never had this guard and has always accepted these URIs correctly. Fix: drop the redundant `path &&`, matching viem exactly. path can never be undefined here - splitUri's third capture group is a mandatory (non-optional) regex group, always at least an empty string. Also corrects an existing pinned test ('behavior: invalid resources') that was unknowingly asserting the bug: with resources set to ['https://example.com', 'foo'], the old code rejected the FIRST entry (a legitimate bare-origin URI) instead of the actually-invalid second one. Fixed code correctly flags 'foo'. * fix(siwe): validate pathless URI authorities --------- Co-authored-by: jxom <7336481+jxom@users.noreply.github.com> (cherry picked from commit 633388e) * fix: validate the authority of `Siwe.isUri` URIs that have a path (#695) `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> (cherry picked from commit ccbb1af) * fix(0.x): accept ip literal `domain` in `Siwe` messages Ports the IP literal domain part of #705 (from #696). Bracketed literals exclude `@` and `[` so a userinfo authority such as `[evil.com@[::1]` cannot pass as a literal. Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1f5cc-eb3a-72b3-bdda-0480feddb7f9 Co-authored-by: jxom <jake@tempo.xyz> --------- Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: jxom <jake@tempo.xyz>
This branch had an error being 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.
Supersedes #696, #698, and #699 by @gomesalexandre (thanks!). Co-authored commit. The three PRs conflicted with each other in
src/core/Siwe.ts, so they land together here.Siwescheme#698):[a-zA-Z0-9+-.]reads+-.as a range that includes,, soht,tpswas accepted. EIP-4361 / RFC 3986 §3.1 schemes have no comma.Siwe.createMessagestatement#699):createMessagenow rejects\r, U+2028 and U+2029 as well as\n, sinceparseMessagereads the statement with.and could not read such messages back.domaininSiwemessages #696): EIP-4361 definesdomain = authority, so[::1]:3000and similar are now accepted bycreateMessageandparseMessage.Changes vs the originals:
domaininSiwemessages #696's new domain check accepted a userinfo authority disguised as a bracketed literal:createMessage({ domain: '[evil.com@[::1]' })succeeded, because the literal regex allowed@and[andnew URLthen read[evil.comas userinfo. The literal regexes (create and parse) now exclude@and[, and[evil.com@[::1]/[a@[::1]are in the invalid-domain tests.Siwescheme#698's escaped scheme hyphen in fix: accept ip literaldomaininSiwemessages #696's rewrittenprefixRegex.The failing "Test Runtime (core)" runs on #698/#699 were RPC flakes against
oxlib.sh/rpc, unrelated to these changes.