Electron Js Asar Integrity Bypass
Electron's ASAR integrity check compares a SHA-256 hash stored in the main executable against a hash computed from the ASAR header. An attacker can modify the ASAR contents, recompute the header hash, and patch the stored hash in the executable to bypass the check.
Published on infosecwriteups.com
I recently created an Electron JS-based Windows and MacOS application. The newer version of Electron has Integrity detection which prevents tampering with the application code.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker who can modify the application's files can bypass the integrity check and run modified code, but this requires local access to the application files.
What the attacker needed
Local access to application files; ability to modify the executable
How it was found
- Extract the ASAR archive to a folder.
- Modify the JavaScript or other files inside the extracted folder.
- Repack the folder into a new ASAR file.
- Compute the new ASAR header hash using the provided script.
- Replace the old hash in the main executable with the new hash using sed or a binary editor.
- Run the application; the integrity check passes.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Electron apps store their code in an archive called an ASAR file. The app checks that this file hasn't been changed by comparing a fingerprint (hash) stored in the main program. The researcher showed that if you change the ASAR file, you can also change the stored fingerprint to match, so the check passes.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.