Bug Bounty Tips And Getting Persistence With Electron Applications
Electron applications such as Signal store their client code in an unpackable and repackable .asar archive inside a user-writable directory, and the application does not verify that the archive is unchanged. An attacker who already has local access to a machine could inject code into the archive and repack it, so that the code runs whenever the victim launches the application.
Published on infosecwriteups.com
With the discord DLL hijacking vulnerability, I noticed a new file type that I couldn’t place .asar. This write-up explains asar files, how you can gain easy persistence with them and how to find other vulnerabilities in them.
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
Root cause
Likely the application loads its .asar archive from a user-writable location without any integrity or hash check, so a modified archive is trusted and executed.
Impact
An attacker with existing local access could achieve persistence by running arbitrary code each time the victim opens the application, though the visible terminal window makes it noisy and the author expects endpoint detection tools to catch it.
What the attacker needed
Local access to the victim's machine; the app installed in a user-writable folder; the asar tool available (npm)
How it was found
- Locate the app.asar file in the application's resources folder under the user's local app data directory.
- Extract the archive with the asar tool into a folder.
- Find package.json to learn the application's start function and main file.
- Insert code that spawns a terminal into the application's show window function.
- Repack the folder back into app.asar.
- Start the application and observe the separate command window launching.
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.
Many desktop apps are built with Electron, a framework that bundles a web app into a program. The app's code sits in a single archive file that the user's own account can read and rewrite. If someone can already log in to your computer, they can edit that file so their own code runs each time you open the app, and the app will not notice the change.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.