pyFlowDroid
Run FlowDroid taint analysis on Android APKs from Python
Quick start · Command line · Python · Coming from 0.2 · Development
Run FlowDroid's taint analysis on Android APKs from Python or the command line. One command sets FlowDroid up; every analysis returns typed results: which data leaks, from which call to which, with line numbers.
Features
- FlowDroid out of the box.
pyflowdroid installfetches the latest FlowDroid release, the sources and sinks list from that same release, and an Android platform: about 54 MB, in seconds. - Typed results.
analyze()returns anAnalysisResultwithLeakobjects (source, sink, method, statement, line), not a log to grep. - Honest failures. When FlowDroid fails, you get an
AnalysisFailedErrorwith the reason and the log, never a silent "0 leaks". - Sample APKs.
pyflowdroid downloadfetches apps from DroidBench, FlowDroid's benchmark with documented leaks, to try things out.
Quick start
You need Java 17 or newer on your PATH (or in JAVA_HOME) and Python 3.11 or newer.
pip install pyflowdroid
pyflowdroid install
pyflowdroid analyze path/to/app.apk
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━┓
┃ APK ┃ Leaks ┃ Seconds ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━┩
│ apks/DirectLeak1.apk │ 1 │ 0.8 │
│ apks/LogNoLeak.apk │ 0 │ 0.6 │
└───────────────────────────┴───────┴─────────┘
apks/DirectLeak1.apk
from TelephonyManager.getDeviceId() in MainActivity.onCreate(), line 27
to SmsManager.sendTextMessage() in MainActivity.onCreate(), line 27
pyflowdroid doctor tells you what is missing if something doesn't work.
Command line
| Command | What it does |
|---|---|
pyflowdroid install |
Download FlowDroid, its sources and sinks list and the Android 36 platform; files already there are kept |
pyflowdroid analyze PATH... |
Analyze APK files and folders (searched recursively); --json prints the results as JSON. Exits 1 if any APK failed |
pyflowdroid download FOLDER |
Download sample APKs (--source droidbench, --count 10) |
pyflowdroid sources |
List where sample APKs can come from |
pyflowdroid doctor |
Check Java and the FlowDroid installation |
python -m pyflowdroid works the same. --verbose shows what happens; --version prints the version.
Python
from pathlib import Path
import pyflowdroid
pyflowdroid.install() # once; skips what is already there
result = pyflowdroid.analyze("app.apk") # -> AnalysisResult
for leak in result.leaks:
print(leak.source.definition, "->", leak.sink.definition, "line", leak.sink.line)
for apk in pyflowdroid.find_apks("apks/"):
try:
print(apk, pyflowdroid.analyze(apk).leaky)
except pyflowdroid.AnalysisFailedError as error:
print(apk, "failed:", error.reason)
pyflowdroid.download("droidbench", 5, Path("apks")) # sample apps
AnalysisResult:apk,leaks(a tuple ofLeak),leaky,flowdroid_version,seconds,log.Leak:sourceandsink, each aStatementwithmethod,statement,definition(the source or sink signature from the list) andline.pyflowdroid.environment()reports what is installed without raising.- Every error derives from
PyFlowDroidError:JavaNotFoundError,UnsupportedJavaError,FlowDroidNotInstalledError,DownloadError(andChecksumMismatchError),InvalidApkError,AnalysisFailedError(andAnalysisTimeoutError),UnknownApkSourceError.
The library doesn't configure logging or print; it logs through the pyflowdroid logger.
How it works
- FlowDroid comes from Maven Central (
de.fraunhofer.sit.sse.flowdroid:soot-infoflow-cmd, thejar-with-dependencies), checked against its published SHA-1. The latest release is used. - Sources and sinks:
SourcesAndSinks.txtfrom the same FlowDroid release, so the list always matches the analysis. - Android platform: one
android.jar(API 36) from Sable/android-platforms, used for every APK. - Everything lives in your user data folder (for example
~/.local/share/pyflowdroidon Linux); setPYFLOWDROID_HOMEto use another folder. - FlowDroid runs as
java -jar … -o results.xml -olwith each argument passed separately (no shell), so paths with spaces work. Each analysis has a 15 minute timeout.
Coming from 0.2
0.9.0 is a rewrite and breaks the old API on purpose.
| 0.2 | 0.9 |
|---|---|
install_deps() downloaded FlowDroid 2.9 and ~1 GB of Android platforms into the installed package |
install(): latest FlowDroid, one platform, in the user data folder |
analyze_apk(path) returned FlowDroid's log as a string |
analyze(path) returns an AnalysisResult |
analyze(folder) returned (count, leaks, leaky_apps) |
find_apks(folder) + analyze() per APK |
fetch(n, "cubapk.com", folder) |
download("droidbench", n, folder); cubapk.com no longer serves APKs |
bundled small.txt / large.txt |
the sources and sinks list of the installed FlowDroid release |
python -m pyflowdroid … |
pyflowdroid … (python -m pyflowdroid still works) |
0.2 no longer works on current Java: FlowDroid 2.9 fails on Java 17 updates and 0.2 reported that as "0 leaks".
Development
Setup, QA and releases: DEVELOPMENT.md. make qa runs the unit tests;
uv run pytest -m e2e --no-cov runs real FlowDroid on DroidBench apps (needs Java 17+ and the network).
Contributing
Issues and pull requests are welcome; make qa must pass.
Acknowledgements
FlowDroid and DroidBench by the Secure Software Engineering group, and Sable/android-platforms. pyflowdroid downloads them; it doesn't redistribute them.
License
MIT: see LICENSE.
🚀 Project starter provided by Cookie Pyrate v1.0.1
Metadata
Release files for pyflowdroid 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyflowdroid-0.9.0.tar.gz | 88.4 kB | Without provenance | Details for pyflowdroid-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyflowdroid-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for pyflowdroid-0.9.0-py3-none-any.whl |
Total release size: 107.0 kB
Release files / pyflowdroid-0.9.0.tar.gz
| Download URL | pyflowdroid-0.9.0.tar.gz |
|---|---|
| Size | 88.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e23e20d9084632b8e941afcbd00aeb5c8f46e7d71b77d9cfa9da4cb5b332ee4
|
|
BLAKE2b-256 checksum How to use checksums |
1bbf8d89e5df5a314c5dd994329a6b9fb34c9a66f4ddf1a609d75cb8a73d069c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyflowdroid-0.9.0-py3-none-any.whl
| Download URL | pyflowdroid-0.9.0-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57ef35dcdb3177181695221391918fef11ec58114fdcf90f2ea4116742ee5a17
|
|
BLAKE2b-256 checksum How to use checksums |
9e1749fbb56e88ceabd7d1018df1972175bfd5828ea20b6552a6be8a424cebe1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pyflowdroid 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.