Repository navigation
fix: read asar contents through the archive's retained file handle - #52292
Merged
Conversation
Reads of packed asar contents re-opened the archive by path on every read, while using file offsets and integrity hashes from the cached header. If the asar on disk was replaced while the app was running (e.g. by an updater or MDM software swapping the app bundle), the fresh open would read the new file's bytes at the old header's offsets, producing either a fatal integrity-check crash in ValidateIntegrityOrDie (browser process) or a spurious ENOENT preload error when the file was briefly missing. Read through the base::File the Archive has held open since the header was validated instead: - Archive::ReadFileAt() does positional reads on the retained handle; asar::ReadFileToString() now uses it, fixing the preload startup data paths and nativeImage reads. - Archive::DuplicateFile() hands streaming consumers a duplicate of the retained handle; AsarURLLoader now uses it for packed files instead of re-opening by path, fixing the equivalent block-hash FATAL in AsarFileValidator for file:// loads. This matches the JS fs wrapper, which has always read through the archive's retained fd. Content served after a swap is the version the app launched with, consistently, until relaunch. In-place tampering is still caught: the retained handle sees modified bytes and the hash check fails as before. Also removes the now-unused Archive::path() accessor so future readers of archive contents can't accidentally reintroduce by-path opens. Co-authored-by: Samuel Attard <[email protected]>
Co-authored-by: Samuel Maddock <[email protected]>
Co-authored-by: Samuel Maddock <[email protected]>
4 tasks done
samuelmaddock
approved these changes
Jul 9, 2026
samuelmaddock
deleted the
trop/44-x-y-bp-fix-read-asar-contents-through-the-archive-s-retained-file-handle-1783570971302
branch
July 9, 2026 18:29
|
Release Notes Persisted
|
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 #52283
See that PR for details.
Notes: Fixed a browser-process crash (
ValidateIntegrityOrDie) and spurious preloadENOENTerrors when an app'sapp.asaris replaced on disk (e.g. by an updater or MDM software) while the app is running.