Authentication-State Rollback / Restore

← Insecure Data Storage

auth_state_rollback_restore   MEDIUM

CategoryInsecure Data Storage
OWASP Mobile (2024)M3
MASVSMASVS-AUTH-1MASVS-STORAGE-2
MASWEMASWE-0006
MASTG (v2 tests)iOSMASTG-TEST-0387AndroidMASTG-TEST-0338
MASTG demosiOSMASTG-DEMO-0150AndroidMASTG-DEMO-0101
CWECWE-384CWE-613CWE-565
PlatformAndroidiOS
Platform notesRestoring a stale local session/token blob (backup, snapshot, copied container) revives an old auth state.

Description

The app treats a locally-persisted session/token as authoritative and never checks freshness/revocation server-side, so restoring an OLD local state (from a backup, snapshot, or copied container) revives an already-ended or revoked session and the app believes the user is still authenticated. The secure path validates the session against a server nonce / revocation list / monotonically-increasing epoch, rejecting rolled-back state.

How it works

The app treats a locally-persisted session/token as authoritative and never checks freshness or revocation server-side. Restoring an old local state (from a backup, snapshot, or copied container) revives an already-ended or revoked session, and the app believes the user is still authenticated. On device the session blob is persisted to the key-value backing file (SharedPreferences XML on Android, a UserDefaults plist on iOS) and resume reads it back from disk, so restoring an old adb-pulled/edited file (or rolling back session_epoch) revives a revoked session. The secure path validates the session against the current server epoch and a revocation list, rejecting rolled-back state while accepting the current session.

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

  1. 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: mitmproxy, sqlite3 · Android: adb, adb backup · iOS: objection, idevicebackup2.
  2. Locate the target. From the home index, open Authentication-State Rollback / Restore (auth_state_rollback_restore). The How it works section above describes this module’s specific weakness; the screen states the intended-secure behavior and exposes the vulnerable action.
  3. Exploit. Exercise the flow that persists data, then inspect on-device storage (adb shell run-as <pkg> / pull the app sandbox, or objection’s android keystore/ios nsuserdefaults helpers) and confirm the sensitive value is present in cleartext or without hardware backing.
  4. 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).
  5. 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.
  6. 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

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:

  • stale session blob

Real-world references

Concrete public disclosures that match this vulnerability class: