Skip to content

fix(0.x): split Tempo WebAuthn data in linear time - #677

Merged
jxom merged 2 commits into
0.xfrom
fix/tempo-webauthn-linear-parse-0.x
Nov 12, 2026
Merged

jxom merged 2 commits into
0.xfrom
fix/tempo-webauthn-linear-parse-0.x

Conversation

@jxom

@jxom jxom commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Backport of #676 to 0.x, so Viem can receive it.

SignatureEnvelope.deserialize and SignatureEnvelope.fromRpc in ox/tempo found the start of clientDataJSON by trying every split offset from 37 and decoding the rest of webauthnData each time. That is quadratic in the size of the data. The 2048-byte limit from #655 bounds the cost; measured on main, where the loop was the same, an envelope with no valid JSON at that limit took 8 to 22 ms to reject, against 0.03 ms for a valid one.

clientDataJSON is the JSON object that ends at the last byte, so one backward pass finds the brace that pairs with that byte and one JSON.parse validates the object. Both copies of the loop now share src/tempo/internal/webauthnData.ts, which matches the file on main except for the @internal tags that this branch's TSDoc check requires.

Behaviour

Compared against the old loop on 300,000 generated inputs on this branch: same result and same thrown error class on every input, with one exception. When a UTF-8 byte order mark sits directly before the JSON, the old loop split before the mark, so the three bytes were lost when the envelope was serialized again. They now stay in authenticatorData. Tempo's node rejects such an envelope either way, because it reads authenticatorData as exactly 37 bytes.

Tests

The new tests count the bytes passed to TextDecoder.decode and JSON.parse for an envelope of nested, unterminated objects, and fail without the fix (1,764,381 bytes decoded against a bound of 1,878).

@vercel

vercel Bot commented Nov 12, 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 12, 2026 4:51am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T04:40:59.002145Z cebe0f1 New commits
ℹ️ 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

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Published [email protected] under the pr-677 dist-tag, which follows this pull request until it closes.

pnpm add ox@pr-677
pnpm add [email protected]

@jxom
jxom merged commit 6f3ff8c into 0.x Nov 12, 2026
14 checks passed
@jxom
jxom deleted the fix/tempo-webauthn-linear-parse-0.x branch November 12, 2026 05:19
@github-actions github-actions Bot mentioned this pull request Nov 12, 2026

This branch was successfully deployed

1 active deployment
Preview — cebe0f15 Deployed Nov 12, 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