Log date · Mon
Is Electron's ASAR encrypted? We packed an app and read it back
Published on · Updated
No. We packed a sample Electron app, read its pricing rules and keys straight back out, then measured what minifying and source maps change. Commands included.
The short answer: no
ASAR is an archive format. It is not encryption, and in our test it was not even compression. We packed a small sample app of eight files (3,645 bytes) and got a 5,721-byte app.asar: a 2,076-byte header followed by the same 3,645 bytes, untouched. One documented command restored every file, comments included, in under a second.
Electron's own documentation is careful about this. It gives three reasons to use ASAR: avoiding long-path problems on Windows, a faster require, and keeping source away from “cursory inspection”. [1] Anything beyond a casual look is outside what the format promises.
The rest of this article walks through the test, then covers what minification and source maps change, what ASAR integrity is for, and where code and secrets should go instead. Every command was run on 2026-11-11 against a sample we wrote ourselves. Run them only on apps you own or are authorized to examine.
| Question | What we found |
|---|---|
| Is the content encrypted? | No. File names and contents are readable with strings. |
| Is it compressed? | No. The archive size equals the header plus the exact sum of the file sizes. |
| Does minifying hide the logic? | Partly. Comments and local names go; numbers, strings, property names and control flow stay. |
| Does ASAR integrity keep code private? | No. It detects modification and does not stop reading (per the documentation; not tested here). |
The sample and the setup
Quote Desk is a made-up desktop quoting tool: a main process, a preload bridge, a renderer page, a pricing module, an offline licence check and a production config file. It holds the two things teams usually worry about: business rules (volume tiers, a loyalty discount, a margin floor) and credentials (an API key and a licence-signing secret, both placeholders).
Tools: @electron/asar 3.4.1, esbuild 0.28.2 and Node.js 20.19.5 on macOS (arm64). We did not launch Electron, because the question here is what sits in the file you ship, not how the runtime loads it.
// src/pricing.js
const VOLUME_TIERS = [
{ minUnits: 500, discount: 0.22 },
{ minUnits: 100, discount: 0.12 },
{ minUnits: 20, discount: 0.05 },
];
// Customers who renew within 30 days of expiry keep their old price
// and get an extra loyalty discount on top of the volume tier.
const LOYALTY_WINDOW_DAYS = 30;
const LOYALTY_DISCOUNT = 0.08;
const FLOOR_MARGIN = 0.31;Step 1: pack it, then look at the file
Packing is one command. Before reaching for any ASAR tool, we ran strings, a standard Unix utility that prints the readable text found in any file.
$ npx asar pack quote-desk app.asar
$ wc -c app.asar
5721 app.asar
$ strings -n 8 app.asar | cut -c1-150
{"files":{"config":{"files":{"production.json":{"size":190,"offset":"0","integrity":{"algorithm":"SHA256","hash":"95fed3cb2977e57de8ed3112515d3eed09c1
$ find quote-desk -type f | xargs cat | wc -c
3645The archive starts with a JSON index naming every folder and file, with each file's size, offset and SHA-256 hash. The format notes in the electron/asar repository describe the same thing: a size field, a JSON header, then the files one after another. [5] The numbers add up exactly: 16 bytes of length prefix, 2,060 bytes of JSON and 3,645 bytes of content make 5,721. Nothing was transformed on the way in.
Step 2: one command restores everything
$ npx asar list app.asar
/config
/config/production.json
/main.js
/package.json
/preload.js
/renderer
/renderer/app.js
/renderer/index.html
/src
/src/license.js
/src/pricing.js
$ time npx asar extract app.asar extracted
real 0m0.822s
$ diff -r quote-desk extracted && echo IDENTICAL
IDENTICALThe extracted folder is byte-identical to the source folder. That includes the comment explaining the renewal rule, the three discount tiers, and config/production.json with both placeholder credentials. Most of the 0.8 seconds is npx starting up.
For a real app the consequence is direct. Anyone who has your installer has your JavaScript as you wrote it, unless a build step changed it before packing. So the next question is how much a typical build step changes.
Step 3: what minification leaves behind
Most production builds bundle and minify. We bundled the main process with esbuild, minified it, packed the result and extracted it again.
$ npx esbuild quote-desk/main.js --bundle --platform=node --external:electron \
--minify --sourcemap --outfile=dist-min/main.js
$ cp quote-desk/package.json dist-min/
$ npx asar pack dist-min min.asar && npx asar extract min.asar audit
$ wc -c audit/main.js
1562 audit/main.js
$ grep -o "minUnits:[0-9]*,discount:[.0-9]*" audit/main.js
minUnits:500,discount:.22
minUnits:100,discount:.12
minUnits:20,discount:.05
$ grep -o "DEMO-[A-Za-z-]*-0000" audit/main.js
DEMO-KEY-not-a-real-credential-0000
DEMO-SECRET-not-a-real-credential-0000The four source files became 1,562 bytes on a single line. The pricing table is still there, digit for digit, and so are both credentials.
| Item | After minifying |
|---|---|
| Comments | Removed |
| Local names (LOYALTY_DISCOUNT, FLOOR_MARGIN) | Replaced by single letters |
| Numbers (0.22, 0.12, 0.05, 30, 0.08, 0.31) | Kept |
| String literals, including both keys | Kept |
| Property names (minUnits, daysSinceExpiry, licenseSigningSecret) | Kept |
| Library calls (createHmac("sha256", …)) | Kept |
Minification is a size optimisation. It removes the explanation but not the rule: the tiers, the 30-day window and the margin floor are all still stated in the file, and a code formatter restores the layout. Treat it as a small increase in reading effort and nothing more.
Step 4: check for source maps
We asked esbuild for a source map on purpose, because shipping one by accident is a common build mistake. The 5,254-byte main.js.map travelled into the archive with everything else.
$ grep -c "Customers who renew" audit/main.js audit/main.js.map
audit/main.js:0
audit/main.js.map:1
$ cat map-check.js
const fs = require("node:fs");
const map = JSON.parse(fs.readFileSync("audit/main.js.map", "utf8"));
const i = map.sources.findIndex((name) => name.endsWith("pricing.js"));
console.log(map.sources.length, "files embedded");
console.log(map.sourcesContent[i] === fs.readFileSync("quote-desk/src/pricing.js", "utf8"));
$ node map-check.js
4 files embedded
trueThe map's sourcesContent field holds all four original files. Its copy of pricing.js is identical to the file on our disk, comments and constant names included. A shipped source map cancels whatever minification removed. Keep maps out of the package and upload them privately to your crash-reporting service instead.
ASAR integrity answers a different question
The SHA-256 hashes in the index belong to a feature called ASAR integrity. When it is enabled, Electron checks the archive at runtime against a hash embedded in the app at packaging time, and terminates on a mismatch. It is supported on macOS from Electron 16 and on Windows from Electron 30, and it is off by default. [2]
You turn it on with the EnableEmbeddedAsarIntegrityValidation fuse. The documentation recommends enabling OnlyLoadAppFromAsar with it, so the check cannot be sidestepped by loading code from elsewhere. [2][3] Electron Forge and Electron Packager generate the hash for you. [2]
This is worth enabling. It makes it harder to distribute a modified copy of your app. It does nothing about reading: the archive stays as legible as in steps 1 and 2. This section summarises the documentation; we did not test integrity enforcement.
Where code and secrets should go instead
Sort what you ship by what it would cost you if someone read it. The table is our recommendation, not something measured above.
| Asset | If it ships in ASAR | What we recommend |
|---|---|---|
| API keys, signing secrets | Readable verbatim (step 3) | Keep them on a server and give the client short-lived, per-user tokens. For offline licences, verify a public-key signature so the client holds no secret. |
| Core algorithm or pricing rules | Readable after formatting | Run it server-side if the feature can be online. If it must work offline, move it into a native module and accept per-platform builds. |
| UI and glue code | Readable | Minify and move on. |
| Source maps | The full original source | Never package them. |
| The archive itself | Can be swapped or edited | Enable ASAR integrity and OnlyLoadAppFromAsar. |
The sample's licence check is a ready-made counter-example. It signs with a shared HMAC secret stored in the client, so anyone who extracts that secret can issue licences. With a public-key signature the client needs only the public key, and that problem disappears.
Two cautions. Native code can still be analysed; moving logic there raises the effort required and does not make recovery impossible. JavaScript obfuscators change how code looks while its behaviour stays observable, so judge them by testing, not by how unreadable the output appears. Spend protection effort on the few modules that carry real value and keep the rest simple.
Run the same check on your own app
Find app.asar inside your packaged build: on macOS under YourApp.app/Contents/Resources/, on Windows and Linux under the resources/ folder next to the executable. [4] Then run these commands against a release build, not a development one.
# 1. What is inside?
npx @electron/asar list path/to/app.asar
# 2. Extract a copy to read
npx @electron/asar extract path/to/app.asar ./audit
# 3. Did any source maps ship?
find ./audit -name "*.map"
# 4. Any credentials in plain text?
grep -rIoiE "(api[_-]?key|secret|token|password)[\"']?[:=] ?[\"'][^\"']{8,}" ./audit \
--include=*.js --include=*.json | cut -c1-120Then open the largest JavaScript file and search for a constant or message you know belongs to your most valuable feature. If you find it in seconds, so will anyone else. Write down what you found, decide item by item using the table above, and repeat the check after every change to your build configuration.
Your checklist
- Extract your release app.asar and read what is in it.
- Remove every .map file from the packaged app.
- Move API keys and signing secrets to a server; use public-key verification for offline licences.
- Decide where each high-value module runs: server, native module or JavaScript.
- Enable ASAR integrity together with OnlyLoadAppFromAsar.
- Repeat the check whenever the build configuration changes.
Primary sources
- Electron documentation: ASAR Archives · Checked 2026-11-11
Read the original here ↗ · Licensed reproduction · MIT
- Electron documentation: ASAR Integrity · Checked 2026-11-11
- Electron documentation: Electron Fuses · Checked 2026-11-11
- Electron documentation: Application Distribution · Checked 2026-11-11
- electron/asar README: command line and archive format · Checked 2026-11-11