Unsafe Media / Image Decoding
← Input Validation (OWASP Mobile M4)
unsafe_media_decoding MEDIUM
| Category | Input Validation (OWASP Mobile M4) |
| OWASP Mobile (2024) | M4 |
| MASVS | MASVS-CODE-4MASVS-PLATFORM-2 |
| MASWE | MASWE-0050 |
| CWE | CWE-20CWE-1284CWE-409 |
| Platform | AndroidiOS |
Description
Untrusted image/media bytes are passed straight to a decoder with no type/size/dimension checks, enabling decompression bombs and codec exploitation (Samsung CVE-2025-21043 class).
How it works
Untrusted media is decoded by trusting its declared header verbatim: no format allowlist, no dimension cap, no byte-length sanity check. A tiny file can declare 100000x100000 pixels, so the decoder tries to allocate widthheight4 bytes (tens of GB) and OOMs the process; spoofed formats reach the codec too (the Samsung CVE-2025-21043 class). This demo actually attempts the declared pixel-buffer allocation as a Uint8List inside a try/catch (clamped to a 2 GiB demo ceiling so the host is not hard-crashed) and reports the real outcome; the thrown OutOfMemoryError/RangeError is the observable over-allocation. The secure path enforces an 8192x8192 cap, a max byte size, and a format allowlist, rejecting the bomb before allocating anything.
How to exercise it. DVMA is the harness - open this module from the home index and tap the demo action. The screen ships the malicious input and simulates the attacker (e.g. the companion app, crafted intent, or scanned payload) in-process, and the evidence panel prints the proof. The Tools (optional) and Attack inputs below are only needed to reproduce the exploit end-to-end on a real device.
Exploit steps
- Set up. Build DVMA with a flavor that enables the Input Validation (OWASP Mobile M4) category (e.g.
--dart-define-from-file=config/flavors/dev.json) and run on an emulator/simulator you control. The demo needs no external tooling; for the optional on-device reproduction the relevant tools are:ImageMagick,radamsa,frida. - Locate the target. From the home index, open Unsafe Media / Image Decoding (
unsafe_media_decoding). The How it works section above describes this module’s specific weakness; the screen states the intended-secure behavior and exposes the vulnerable action. - Exploit. Feed the crafted/malformed input (serialized blob, intent extra, media file, deep link) into the parsing path and confirm the app trusts it - state change, crash/DoS, or code path it should reject.
- Observe the evidence. Trigger the vulnerable action and read the evidence panel - it prints the concrete proof (leaked value, accepted replay, executed payload, or unauthorized result).
- Contrast with the secure path. Run the module’s secure/hardened action (where provided) and confirm the same attack is rejected - this is what a correct implementation should do.
Tools (optional)
Attack inputs
Payloads/artifacts you author for the on-device attack. The demo already ships and simulates these in-process (e.g. the malicious companion app / crafted intent is emulated inside the screen), so you only need to craft them to reproduce the exploit on a real device:
crafted image