The Problem

APK files bundle compiled bytecode, resources, and metadata that often contain hardcoded endpoints, API keys, and other secrets. Manually decompiling and grepping for these patterns is slow and error-prone. APKLeaks automates the discovery of URIs, endpoints, and secrets inside an APK by decompiling it and scanning the result against a set of regex patterns.

What This Does

APKLeaks is a Python CLI tool that takes an APK file, decompiles it using jadx, and scans the decompiled source for sensitive patterns. The default patterns live in config/regexes.json; users can supply their own via a --pattern argument. Results can be written to a text or JSON file.

The codebase is small: 6 Python files, with the core logic in apkleaks/apkleaks.py and helper functions in apkleaks/utils.py. It ships with a Dockerfile, a Makefile, and GitHub Actions workflows for CI and publishing.

How It Is Wired

Execution starts at main in apkleaks/cli.py:32. That function reaches 11 other functions, making it the single entry point through which all control flows. The call graph shows the main path: main calls APKLeaks, integrity, and decompile; integrity calls dependencies and apk_info; and decompile calls extract and cleanup.

The two most-connected modules are apkleaks/apkleaks.py (8 functions, 1 class) and apkleaks/utils.py (3 functions, 1 class). Both have an instability score of 0.67, meaning they are relatively volatile. The function writeln in utils.py is called from 6 different places — the widest blast radius in the repo. Changing its signature or behavior will ripple through most of the tool's output handling.

A full run does the following: mainAPKLeaksintegrity (checks jadx availability) → decompileextractscanningwriteln (writes results to disk). The tool touches the filesystem for the APK, the decompiled output, and the results file; it invokes an external process (jadx) for decompilation. No network calls or database writes are present.

File-by-file map:

  • apkleaks/cli.py — argument parsing, header, main
  • apkleaks/apkleaks.py — core orchestration: apk_info, dependencies, integrity, decompile, extract, scanning, cleanup
  • apkleaks/utils.pywrite, writeln, finder (regex matching), utility class
  • apkleaks/colors.py — ANSI color output
  • config/regexes.json — default secret patterns

How To Use It

Setup — Install from PyPI or clone and install requirements:

pip3 install apkleaks
# or from source
git clone https://github.com/moses-y/apkleaks
cd apkleaks/
pip3 install -r requirements.txt

Running it — The CLI entry point is apkleaks, or python3 apkleaks.py from source:

apkleaks -f /path/to/file.apk -o results.txt
apkleaks -f /path/to/file.apk -p custom-rules.json --json

Configuration — No environment variables are required. Custom patterns go in a JSON file passed via -p. The jadx disassembler must be installed or available for download.

Real-World Use

A security engineer auditing a mobile app before release would run:

apkleaks -f app-release.apk -o audit-results.txt --json

The output file lists all matched endpoints and secrets, which can then be triaged — hardcoded API keys get revoked, exposed internal endpoints get reviewed. The custom pattern file lets the team add org-specific patterns (e.g., internal hostnames) without modifying the tool.

Code Health & Issues

Static analysis found 6 issues: 1 high, 5 medium.

  • High - Deep nestingapkleaks/utils.py and apkleaks/apkleaks.py have max indentation depth of 8, making control flow hard to follow. Fix with guard clauses and early returns.
  • Medium - File opened without context managerapkleaks/cli.py uses open(...) without with, risking a leaked handle on error.
  • Medium - Broad exception handlingexcept clauses in apkleaks/apkleaks.py, apkleaks/cli.py, and apkleaks/utils.py swallow errors indiscriminately.

SDLC observations: no test files exist, and dependencies are declared without a lockfile (pyproject.toml), so builds are not reproducible. CI exists via GitHub Actions, and no committed secrets were detected.

The Bottom Line

A functional, focused tool that does one job well. The lack of tests and lockfile makes it risky to modify, but the small codebase is easy to read and the core logic is straightforward. Suitable for security engineers who need a quick APK secret scanner and are willing to accept the maintenance risk.