Skip to content
Asar Py Issues 4

Asar Py Issues 4

github.com • November 25, 2026

Extracting an attacker-supplied .asar archive with asar.extract_archive() or AsarArchive.extract() writes files anywhere the user can write. Entry names from the archive's JSON header are joined to the output directory without any check, so a directory node named .. walks out of it, and link entries can point anywhere. Writing a Python usercustomize.py into the user site directory turns this into code execution the time Python starts. Local, user interaction (extract the archive), high impact (CVSS 7.8).

When an archive is opened for reading, _parse_metadata builds each entry's path from the keys of the header's files objects, as given ( asar/asar.py:217-219 , cur_path = path_in / name ). extract then writes every entry to dst / meta.path :

There is no resolve() / relative_to() or commonpath containment check, so .. path components in the header escape dst . A link entry creates a symlink to an arbitrary target ( asar.py:192-199 ), and an entry marked unpacked copies .unpacked/ into the output ( asar.py:232 , :203 ), so the same unchecked path also gives a local file read into the output directory. The only .. check in the module (line 112) applies to symlinks when creating an archive, not when extracting one. The attacker controls the whole header; no option disables this.

The PoC hand-builds a minimal valid .asar (16-byte size prefix, JSON header, data) whose header nests directory nodes named .. above a file entry, then extracts it with the public extract_archive . The file is a benign marker written to /tmp , outside the out/ directory.

Observed: /tmp/asar_poc.txt is created with the marker content. Pointing the nested path at /.local/lib/python3.13/site-packages/usercustomize.py instead writes a module that Python imports at every start; that variant was verified to run code on the python3 -c pass . Control: the same tree without the .. hops is extracted inside out/ and nothing is written elsewhere; the .. nodes are the only difference. Tested on asar 0.1.3 (PyPI) and main 64b130bc , Python 3.13, Linux.

Anyone who extracts an .asar they did not build can have arbitrary files written or overwritten with their privileges (shell start-up files, SSH authorized_keys , Python user-site modules). app.asar is the archive every Electron application ships, and unpacking third-party Electron apps is a routine step in reverse engineering, malware triage, modding and localisation work.

Contain every extracted path in AsarArchive.extract ( asar/asar.py ): resolve cur_dst and refuse the entry unless it stays under the resolved dst ; do the same for the symlink target and for the unpacked source under asar_unpacked . Rejecting .. and absolute names already in _parse_metadata (line 218) is a cheap second layer, since that is where header names enter.

Path.is_relative_to needs Python 3.9; on older versions use os.path.commonpath . A regression test should extract a header with a .. node and expect ValueError .

Project:

Source: asar-py/asar/asar.py Line 190 in 64b130b cur_dst = dst / meta . path

Affected versions: <= 0.1.3 and main HEAD (64b130bc)

Patched versions: none

Severity: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Dilanka Kaushal Hewage (r3vpwnx) [email protected]

black-06 added 2 commits that reference this issue on Nov 25, 2026 fix: path traversal when extracting an archive allows arbitrary file … 31d836c fix: path traversal when extracting an archive allows arbitrary file … d978a7e

fix: path traversal when extracting an archive allows arbitrary file …

fix: path traversal when extracting an archive allows arbitrary file …

black-06 closed this as completed on Nov 25, 2026

Extracted Entities

Attack Types (1)

CWE Weaknesses (1)

Platforms (3)

Tools (1)