/

CVE-2026-39973

Severity:

HIGH RISK

(7.1)

Path Traversal in Apktool Resource File Decoder

CVE-2026-39973

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write / Potential Remote Code Execution

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Apktool versions 3.0.0 and 3.0.1 contain a path traversal vulnerability in the resource file decoder that allows a crafted APK to write files outside the intended output directory during decoding (apktool d).

By embedding ../ sequences in resource names, an attacker can cause arbitrary files to be written to sensitive locations on the host system, which can ultimately lead to remote code execution when those files are later executed or sourced by the user or operating system.

Affected context

This vulnerability affects environments where Apktool 3.0.0 or 3.0.1 is used to decode untrusted or third-party APK files.

The issue is specific to the resource decoding logic in ResFileDecoder.java, where output paths derived from APK resource names are not sanitized before being written to disk.

It becomes risky when developers, analysts, CI systems, or automated pipelines run apktool d against APKs obtained from external, possibly malicious sources and allow the resulting files to be written into directories where sensitive configuration or startup files reside.

Exploit preconditions

  • Attack surface: Local execution of Apktool (apktool d) against a malicious APK.
  • Required access: Ability to supply or influence the APK being analyzed or decoded (e.g., via file upload, repository contribution, or sample intake pipeline).
  • Trigger point: Running the decode command on the crafted APK; the vulnerable code runs as part of standard resource decoding.
  • Why exploitation is possible: Resource names drawn from the resources.arsc Type String Pool are used directly to construct filesystem paths without path sanitization, allowing embedded ../ segments to escape the intended output directory and target arbitrary locations on the host filesystem.

Why this happens

The underlying bug is a missing path canonicalization and validation step in the resource decoding pipeline, mapping directly to CWE-22: Path Traversal.

Historically, Apktool invoked BrutIO.sanitizePath() to normalize and constrain file paths to the expected output directory.

In versions 3.0.0 and 3.0.1, a regression removed this call in ResFileDecoder.java, causing the application to trust resource-derived paths from the APK.

As a result, attacker-controlled ../ sequences in resource names are treated as legitimate path elements, allowing writes outside the designated decode directory.

Potential impact

  • Malicious APKs may cause arbitrary files to be created or overwritten on the host filesystem.
  • Critical user configuration files (e.g., ~/.ssh/config, ~/.bashrc, or shell profile scripts) could be overwritten, enabling command execution on next use or login.
  • On Windows, files may be written into Startup folders or other auto-run locations, leading to execution on next reboot or login.
  • Existing application configuration files or scripts can be corrupted, causing denial of service or unexpected behavior.
  • Persistent backdoors or malicious configurations can be planted that survive across sessions.

General mitigation guidance

Defensive measures center on treating APK contents as untrusted input and constraining all filesystem interactions:

  • Ensure all output paths derived from archive contents are normalized and validated against a configured base directory before file creation.
  • Apply strict path canonicalization routines that collapse .. segments and reject paths that attempt to traverse outside the decode root.
  • Use secure I/O helpers or abstractions that enforce directory jail semantics and prevent arbitrary path escapes.
  • Run tools like Apktool in isolated working directories with minimal privileges (e.g., dedicated throwaway user accounts, containers, or sandboxes) so that even if a path escape occurs, it cannot impact sensitive locations.
  • Avoid decoding untrusted APKs in directories that contain security-sensitive or auto-executed files such as shell profiles, SSH config, or startup folders.

How teams detect issues like this

Effective detection focuses on both code-level and operational signals:

  • Static analysis: Search for file write operations in decoding or extraction code that construct paths from archive-derived strings without passing through a path sanitization or canonicalization function. Flag instances where ../ or absolute paths are not explicitly handled.
  • Code review: During review of file extraction or reverse-engineering tooling, verify that all untrusted paths are constrained to a root directory and that path-joining helpers enforce this invariant. Look for regressions where security helper calls (like sanitizers) were removed or bypassed.
  • Runtime monitoring: In hardened environments, monitor tools like Apktool for file creation or modification events outside expected working directories when processing untrusted APKs.
  • Policy enforcement: Incorporate checks into CI or build pipelines to ensure that tools interacting with untrusted archives use approved safe I/O utilities and that decoding occurs within controlled, disposable environments. Automated security linters or SAST tools can assist in flagging unsafe path usage patterns.

Sources

SourceLink
github.comgithub.com/iBotPeaches/Apktool/commit/e10a0450c7afcd9462c0b76bcbff0e7428b92bdd#diff-cd531ebe1014bfd18185bf21585ca5cdb16fbcb07703ebc47949a1b4e4e36bc3
github.comgithub.com/iBotPeaches/Apktool/pull/4041
github.comgithub.com/iBotPeaches/Apktool/releases/tag/v3.0.2
github.comgithub.com/iBotPeaches/Apktool/security/advisories/GHSA-m8mh-x359-vm8m

Frequently asked

questions

Not directly in a network sense. Exploitation requires someone or some automated process to run Apktool against a malicious APK. However, in workflows where users or CI systems routinely decode externally supplied APKs, an attacker can achieve effective remote impact by delivering such an APK.

The attacker does not need shell access, but they must be able to supply or influence the APK that gets decoded—via file sharing, repository contributions, malware submission portals, or other intake channels that eventually feed into Apktool-based analysis or processing.

Reintroduce and consistently use robust path sanitization before any file write, ensuring that all archive-derived paths are resolved relative to a known base directory, rejecting any paths that attempt to traverse outside it. Centralizing path handling in a well-reviewed utility function helps avoid regressions.

Treat all archive contents as untrusted, enforce strict directory confinement for extraction/decoding logic, and integrate security-focused tests and static checks for path traversal into the development and review process. Running reverse-engineering tools in least-privilege, isolated environments further reduces the impact of any path-handling flaws that slip through.

Find out what's already
exploitable in your codebase.