Repository navigation
Add OS-backed Web Crypto secure random - #103
Merged
wieslawsoltes merged 1 commit intoSep 15, 2026
Merged
wieslawsoltes merged 1 commit into
wieslawsoltes merged 1 commit into
Conversation
wieslawsoltes
merged commit Sep 15, 2026
23c76bf
into
feature/code-oss-browser-compatibility
4 of 7 checks passed
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.
Problem and resulting behavior
WebScene's V8 bootstrap implemented
crypto.getRandomValues()withMath.random(), filled only 8 bits per array element, accepted floating-point views and oversized requests, and omittedcrypto.randomUUID(). Unchanged VS Code OSS 1.137 reaches secure random in its browser workbench and worker extension host for UUIDs, authentication nonces/verifiers, WebSocket keys/masks, and built-in extension identifiers.This change replaces that path with one native operating-system CSPRNG service:
getentropy()calls;getrandom()with interruption handling;BCryptGenRandom()with the system-preferred provider.getRandomValues()now fills the view's exact byte range, accepts only integer TypedArrays, enforces the 65,536-byte quota before mutation, returns its argument by identity, and preserves Crypto receiver checks.randomUUID()emits canonical RFC 4122 version 4 UUIDs from the same native source. The binding is installed consistently in window, hydrated iframe, and dedicated-worker realms.There is no PRNG fallback.
crypto.subtleremains absent because WebScene does not yet have a vetted cross-platform provider and completeCryptoKeysemantics; that work is scoped separately in #102. The VS Code call inventory and this boundary are documented indocs/code-oss-compatibility.md.Closes #101.
Validation
webscene_hybrid_v8_runtime_testscompiled and passed on macOS ARM64.-Wall -Wextra -Werror), and Windows 11 ARM64/MSVC (0.60 s).webscene_secure_random_tests,webscene_hybrid_v8_runtime_tests).The 4,096-call performance gate has a two-second budget to reject per-byte syscall regressions while allowing normal hosted-runner variance.