Skip to content

fix(Siwe): tighten scheme, statement, and IP literal domain validation - #705

Merged
jxom merged 1 commit into
mainfrom
external/siwe-696-698-699
Nov 19, 2026
Merged

jxom merged 1 commit into
mainfrom
external/siwe-696-698-699

Conversation

@jxom

@jxom jxom commented Nov 19, 2026

Copy link
Copy Markdown
Member

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.

Changes vs the originals:

The failing "Test Runtime (core)" runs on #698/#699 were RPC flakes against oxlib.sh/rpc, unrelated to these changes.

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>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ox Error Error Nov 19, 2026 10:22pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T22:21:58.355101Z 80931b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Published ox@0.0.0-pr-705-80931b8 under the pr-705 dist-tag, which follows this pull request until it closes.

pnpm add ox@pr-705
pnpm add ox@0.0.0-pr-705-80931b8

@jxom
jxom merged commit 061ebb0 into main Nov 19, 2026
14 of 15 checks passed
@jxom
jxom deleted the external/siwe-696-698-699 branch November 19, 2026 22:28
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>
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026
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

1 failed deployment
Preview — 80931b84 Deployed Nov 19, 2026 by vercel[bot]
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.

2 participants