Skip to content

fix: invalidate sandboxed preload code cache when source changes without changing length#51930

Merged
MarshallOfSound merged 1 commit into
mainfrom
fix/preload-code-cache-source-hash
Jun 9, 2026
Merged

fix: invalidate sandboxed preload code cache when source changes without changing length#51930
MarshallOfSound merged 1 commit into
mainfrom
fix/preload-code-cache-source-hash

Conversation

@VerteDinde

@VerteDinde VerteDinde commented Jun 9, 2026

Copy link
Copy Markdown
Member

Description

The sandboxed preload code cache (#51602) relied on V8's CachedData validation to reject stale blobs, but V8's source check hashes only the source length. Updating a preload without changing its byte length made renderers silently run the old version's bytecode.

Cache entries are now bound to the sha256 of the preload source: the renderer ships the hash of what it compiled with the produced blob, and the browser only serves a blob whose recorded hash matches the contents it just read. The browser also rejects cache writes for preload ids not served to the sending frame. Old-format cache files read as a miss and self-heal.

Checklist

  • PR description included
  • npm test passes (preload code cache suite)
  • tests are added/updated

Release Notes

Notes: Fixed sandboxed preload scripts running a stale cached version after the script was modified without its file size changing.

@VerteDinde VerteDinde added semver/patch backwards-compatible bug fixes target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Jun 9, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jun 9, 2026
…out changing length

V8's CachedData source check hashes only the source length, so a preload
edit that preserves byte length consumed the stale blob and ran the old
bytecode. Bind cache entries to sha256 of the source: the renderer ships
the hash of what it compiled, the browser stores it in the cache entry
and only serves a blob whose hash matches the contents it just read.
Reject cache writes for preload ids not served to the sending frame.
@VerteDinde VerteDinde force-pushed the fix/preload-code-cache-source-hash branch from 713c479 to 6149a92 Compare June 9, 2026 00:08
@VerteDinde VerteDinde marked this pull request as ready for review June 9, 2026 00:32
@MarshallOfSound MarshallOfSound merged commit 0383e49 into main Jun 9, 2026
72 checks passed
@MarshallOfSound MarshallOfSound deleted the fix/preload-code-cache-source-hash branch June 9, 2026 03:52
@release-clerk

release-clerk Bot commented Jun 9, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed sandboxed preload scripts running a stale cached version after the script was modified without its file size changing.

@trop

trop Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #51932

@trop trop Bot added in-flight/43-x-y and removed target/43-x-y PR should also be added to the "43-x-y" branch. labels Jun 9, 2026
@trop

trop Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #51933

@trop trop Bot added in-flight/42-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. and removed target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/42-x-y in-flight/43-x-y labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. new-pr 🌱 PR opened recently semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants