MarshallOfSound

#55171: fix: validate asar header and entry sizes against the archive length

Merged
Created: Oct 21, 2026, 1:22:39 PM
Merged: Oct 21, 2026, 2:15:06 PM
5 comments
Target: main

Description of Change

Before: the native asar reader used the archive's header size field and each entry's size/offset as-is. A truncated or otherwise malformed archive (header size larger than the file, a negative entry size, or an entry extending past the end of the file) could make fs calls on it fail in confusing ways rather than reporting a clean error.

After: the header size is checked against the archive's actual length when the archive is opened, and entries whose size is negative or whose range does not fit inside the archive are treated as missing. This matches the validation @electron/asar already does in JS, so malformed archives now surface as "Invalid package" / ENOENT consistently across both readers.

How: Archive::Init() records the file length and rejects an oversized header before reading it; FillFileInfoWithNode() takes the file length and bounds-checks offset + size against it. Specs build small malformed archives on the fly and assert the fs wrapper reports them as invalid/missing.

Checklist

Release Notes

Notes: Fixed handling of malformed asar archives whose size fields do not match the file length.

Backports

43-x-y
Merged
PR Number
#55179
Merged At
Oct 21, 2026, 4:09:21 PM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#55176
Merged At
Oct 21, 2026, 3:20:09 PM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#55175
Merged At
Oct 21, 2026, 3:20:23 PM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron