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.arscType 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.

