Repository navigation
fix(0.x): split Tempo WebAuthn data in linear time - #677
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 |
Merged
This branch was successfully 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.
Backport of #676 to
0.x, so Viem can receive it.SignatureEnvelope.deserializeandSignatureEnvelope.fromRpcinox/tempofound the start ofclientDataJSONby trying every split offset from 37 and decoding the rest ofwebauthnDataeach time. That is quadratic in the size of the data. The 2048-byte limit from #655 bounds the cost; measured onmain, 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.clientDataJSONis the JSON object that ends at the last byte, so one backward pass finds the brace that pairs with that byte and oneJSON.parsevalidates the object. Both copies of the loop now sharesrc/tempo/internal/webauthnData.ts, which matches the file onmainexcept for the@internaltags 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 readsauthenticatorDataas exactly 37 bytes.Tests
The new tests count the bytes passed to
TextDecoder.decodeandJSON.parsefor an envelope of nested, unterminated objects, and fail without the fix (1,764,381 bytes decoded against a bound of 1,878).