Local Security-State Integrity Tampering
local_security_state_integrity_tampering MEDIUM
| Category | Insecure Data Storage |
| OWASP Mobile (2024) | M9 |
| MASVS | MASVS-STORAGE-2MASVS-AUTH-1 |
| MASWE | MASWE-0006 |
| MASTG (v2 tests) | iOSMASTG-TEST-0387AndroidMASTG-TEST-0338 |
| MASTG demos | iOSMASTG-DEMO-0150AndroidMASTG-DEMO-0101 |
| CWE | CWE-565CWE-345CWE-602 |
| Platform | AndroidiOS |
| Platform notes | SharedPreferences/SQLite (Android) or UserDefaults/plist/SQLite (iOS) that gate a security decision. |
Description
A security decision (authenticated?, role, jailbreak-check result, purchase entitlement) is driven by a locally-persisted value in UserDefaults/SharedPreferences/SQLite that carries no integrity protection, so an attacker with local access flips the value and the app trusts it - no secret is stolen, the app is made to trust attacker-controlled STATE. The secure path binds security state to a keyed MAC / server authority (OWASP MASTG-BEST-0065 storage-integrity class).
How it works
A security decision (role, purchase entitlement) is read straight from a locally-persisted value that carries no integrity protection. An attacker with local access flips the stored value (role=admin, entitlement=premium) and the app trusts it; no secret is stolen, the app is simply made to trust attacker-controlled state. The state is persisted to an on-device SQLite database, so it can be pulled via adb or a rooted/jailbroken device and edited with sqlite3. The secure path binds each value to a keyed MAC and fails closed when the tag does not verify, while still honoring legitimately-written state.
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 Insecure Data Storage 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:sqlite3,xxd· Android:adb,SharedPreferences/XML inspection· iOS:objection,plutil,plist inspection. - Locate the target. From the home index, open Local Security-State Integrity Tampering (
local_security_state_integrity_tampering). 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. Exercise the flow that persists data, then inspect on-device storage (
adb shell run-as <pkg>/ pull the app sandbox, orobjection’sandroid keystore/ios nsuserdefaultshelpers) and confirm the sensitive value is present in cleartext or without hardware backing. - 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.
- Map it back. Cross-reference the MASTG v2 test(s) MASTG-TEST-0338, MASTG-TEST-0387 for the canonical procedure and remediation.
Tools (optional)
Android
adbSharedPreferences/XML inspection
iOS
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:
edited preference/db value
Real-world references
Concrete public disclosures that match this vulnerability class: