crypto: harden X509Certificate state - #65518
Open
panva wants to merge 3 commits into
Open
Conversation
Measure construction and low-cost method paths for crypto classes whose state is stored in native or private slots. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Cache constructor-known KeyObject types in the existing private slot until a native handle is needed. Prime normal CryptoKey slot arrays from constructor arguments while retaining the native fallback for transferred keys. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Construct X509Certificate instances directly on the existing native X.509 wrapper and keep lazy cached values in private state. Use a non-throwing native brand check while preserving the existing structured-clone behavior. Preserve derived-constructor prototype semantics without rereading new.target.prototype. Add coverage for receiver validation, hidden state, prototype edge cases, subclassing, and structured cloning through workers and message ports. Replace the key-only instanceof lint rule with a module-aware crypto class guard and extend it to X509Certificate. Resolve references by lexical binding so shadowed constructor names remain valid. Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Collaborator
|
Review requested:
|
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65518 +/- ##
========================================
Coverage 90.14% 90.15%
========================================
Files 751 751
Lines 253585 253707 +122
Branches 47772 47808 +36
========================================
+ Hits 228596 228719 +123
+ Misses 16228 16220 -8
- Partials 8761 8768 +7
🚀 New features to boost your workflow:
|
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.
This follows the prior
KeyObjectandCryptoKeyhardening done in #63111 and applies the same native/private-slot model toX509Certificate.Construct
X509Certificateinstances directly on the native X.509 wrapper instead of storing the wrapper and lazy cache behind observable symbols. Cached values remain in private state, receiver validation uses a native brand check.Furthermore, given the learnings from hardening
X509Certificatewithout losing performance, cache constructor-knownKeyObjecttypes and normalCryptoKeyslots while retaining the native fallback for transferred keys.The added benchmark comparison shows no statistically significant regressions. Only improvements in construction and property access across the three hardened classes.