crypto,lib: read WebCrypto inputs through primordials - #65115
Open
panva wants to merge 3 commits into
Open
Conversation
Member descriptors are plain object literals that spell out only the members they need, so createDictionaryConverter() reading the optional validator, defaultValue and required members off them resolves through %Object.prototype%. Copy each descriptor once at construction time with every key present. They keep an ordinary prototype because a null-prototype object literal lands in V8 dictionary mode, and dictionaries with no defaults and no required members now skip steps 4.1.5 and 4.1.6. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
BufferSource conversion hands over the caller's own object uncopied, so byteLength, byteOffset, buffer and length reads on it run user-replaceable prototype accessors. Internal lookup tables are indexed with computed keys, so a polluted %Object.prototype% key answers a miss. The %Set% constructor iterates its argument through the user-mutable %Array.prototype% iterator. The algorithm registry and the hash name tables are detached from %Object.prototype% after construction rather than declared `__proto__: null`, which V8 places in dictionary mode. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Collaborator
|
Review requested:
|
RafaelGSS
approved these changes
Aug 7, 2026
This comment was marked as outdated.
This comment was marked as outdated.
avivkeller
approved these changes
Aug 7, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65115 +/- ##
========================================
Coverage 90.29% 90.30%
========================================
Files 759 759
Lines 248295 248404 +109
Branches 46861 46872 +11
========================================
+ Hits 224205 224328 +123
+ Misses 15517 15509 -8
+ Partials 8573 8567 -6
🚀 New features to boost your workflow:
|
Collaborator
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.
A pass over the Web Crypto implementation from a primordials perspective, continuing where #63363 left off. That one covered the promise/thenable side, this covers input validation and normalization.
Per our threat model, prototype pollution requiring control over user input is not a vulnerability so this is hardening and spec-fidelity work rather than a security fix.
Three things covered:
The obvious (
__proto__: null) fix regresses badly: V8 creates__proto__: nullobject literals in dictionary mode and constant-folds absent-property loads through a stable%Object.prototype%chain. Applied naively that cost -88% onwebidl-dict-nulland -24% onnormalizeAlgorithm-string. Instead, tables are detached withObjectSetPrototypeOf()after construction, options and descriptors spell out every key they read, and dictionaries needing no missing-member handling skip those reads.benchmark/misc/webcrypto-webidl, 25 runs, medians:normalizeAlgorithm-stringnormalizeAlgorithm-dictwebidl-dictwebidl-dict-nullwebidl-dict-enforce-rangewebidl-dict-ensure-shaAll within noise.