Repository navigation
Description
Preflight Checklist
- I have read the [contribution documentation](https://github.com/electron/packager/blob/main/CONTRIBUTING.md) for this project.
- I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project follows, as appropriate.
- I have searched the issue tracker for a bug that matches the one I want to file, without success.
Issue Details
-
Electron Packager Version:
- 20.0.2
-
Electron Version:
- 43.1.1
-
Node Version:
- 24.18.0
-
Operating System:
- Windows 11 x64 (
win32 10.0.26200)
- Windows 11 x64 (
-
Last Known Working Electron Packager version:
- Unknown
Expected Behavior
When providing a custom Windows application manifest through:
win32metadata: {
'application-manifest': manifestPath
}Electron Packager should embed the exact contents of the manifest file into the generated executable as the RT_MANIFEST resource.
The resulting executable should start normally and Windows should be able to parse the embedded manifest.
Actual Behavior
The generated executable contains a corrupted manifest resource and fails to start with the following Windows error:
The application has failed to start because its side-by-side configuration is incorrect.
Running sxstrace shows:
INFO: Parsing Manifest File ...\MyTube.exe.
INFO: Manifest Definition Identity is (null).
ERROR: Line 0: XML Syntax error.
ERROR: Activation Context generation failed.
The source manifest itself is valid XML.
The issue appears to come from the following code in resedit.js:
manifestEntry.bin = Buffer.from(
await promisifiedGracefulFs.readFile(
options.win32Metadata?.['application-manifest']
)
).buffer;Buffer.buffer returns the underlying ArrayBuffer, which may include bytes outside the actual Buffer range due to its byteOffset and the size of its backing buffer.
Changing the implementation to slice only the actual Buffer contents fixes the generated executable:
const manifestBuffer = await promisifiedGracefulFs.readFile(
options.win32Metadata?.['application-manifest']
);
manifestEntry.bin = manifestBuffer.buffer.slice(
manifestBuffer.byteOffset,
manifestBuffer.byteOffset + manifestBuffer.length
);After applying this change:
- The custom manifest is correctly embedded in the generated
.exe. - Resource Hacker shows the expected custom manifest contents.
- Windows successfully starts the application.
- A Squirrel installer created from the packaged application installs successfully.
There is already a similar implementation in the same file for the ASAR integrity resource:
bin: integrityBuffer.buffer.slice(
integrityBuffer.byteOffset,
integrityBuffer.byteOffset + integrityBuffer.length
)To Reproduce
Use the Electron Packager API with a custom Windows application manifest:
import { packager } from '@electron/packager';
await packager({
dir: './app',
out: './output',
platform: 'win32',
arch: 'x64',
overwrite: true,
win32metadata: {
'application-manifest': './manifest.xml'
}
});Use a minimal custom manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="com.example.application"
version="1.0.0.0"
processorArchitecture="*" />
</assembly>Package the application and attempt to run the generated executable.
With the current implementation, Windows may fail while parsing the embedded manifest with:
ERROR: Line 0: XML Syntax error.
After changing the manifest resource assignment to preserve only the Buffer's actual byte range:
const manifestBuffer = await promisifiedGracefulFs.readFile(
options.win32Metadata?.['application-manifest']
);
manifestEntry.bin = manifestBuffer.buffer.slice(
manifestBuffer.byteOffset,
manifestBuffer.byteOffset + manifestBuffer.length
);the same application packages and runs successfully.
Additional Information
The problem appears to be caused by passing the complete underlying ArrayBuffer from a Node.js Buffer instead of the Buffer's actual byte range.
The same potentially unsafe pattern also exists in the requested-execution-level branch:
const newContent = currentManifestContent.replace(/* ... */);
manifestEntry.bin = Buffer.from(newContent, 'utf-8').buffer;This code may be affected by the same issue and could potentially use the same byteOffset / length approach.
The ASAR integrity implementation in the same file already handles this correctly by slicing the underlying ArrayBuffer to the actual Buffer range.
I can provide additional sxstrace output or help validate a fix if needed.
Activity
electron-npm-package-publisher commentedon Jul 16, 2026
🎉 This issue has been resolved in version 20.0.3 🎉
The release is available on:
Your semantic-release bot 📦🚀