Skip to content

fix(0.x): port Siwe authority validation (#434, #695) and ip literal domains (#705) - #709

Merged
jxom merged 3 commits into
0.xfrom
fix/0.x-siwe-authority
Nov 19, 2026
Merged

jxom merged 3 commits into
0.xfrom
fix/0.x-siwe-authority

Conversation

@jxom

@jxom jxom commented Nov 19, 2026

Copy link
Copy Markdown
Member

Ports main's Siwe authority validation to 0.x and adds IP-literal domain support on top. This finishes the 0.x side of #705 and ports #695, both of which #706 had to leave out.

Not included: main's unrelated Siwe changes, which are RFC 3339 date-time parsing (#398) and the stricter chainId check.

0.x adaptation: 0.x's vitest doesn't allow inline snapshots inside test.each, so those two assertions use .toBe(false).

Local results:

gomesalexandre and others added 3 commits November 19, 2026 22:41
* 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)
`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)
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>
@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 Ready Ready Preview Nov 19, 2026 10:50pm 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:43:58.894340Z 6b9504b 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.

@jxom
jxom merged commit 0cd7550 into 0.x Nov 19, 2026
14 checks passed
@jxom
jxom deleted the fix/0.x-siwe-authority branch November 19, 2026 22:50
@github-actions github-actions Bot mentioned this pull request Nov 19, 2026

This branch was successfully deployed

1 active deployment
Preview — 6b9504bb 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.

3 participants