At a glance
- Controls
- CWE-922 · A01:2021 Broken Access Control
What it is
Web apps often keep session or access tokens in local storage, which any script on the page can read. Mobile apps sometimes write tokens to shared files, plain preferences or the device log. These places offer no protection if other code runs nearby.
A single cross-site scripting flaw, a bad third-party script or a malicious app on the device can copy the token. The attacker then calls the API as that user until the token expires. AI-assisted attackers can read app bundles quickly to find where tokens are written.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Front-end auth code that writes tokens to localStorage or sessionStorage
- Mobile shared preferences, plain files and debug logging
- Refresh tokens with long lifetimes kept on the client
- Third-party scripts loaded on pages that hold tokens
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Read the front-end and mobile code to find where tokens are saved after sign-in.
- 02Sign in as a test user and inspect browser storage, cookies and device logs for the token.
- 03Show that page script can read the token, using only the tester's own session.
Tokens must be stored only in protected storage.
Executable checkas user A: sign in through the web app expect: no token in localStorage or sessionStorage expect: session cookie set with HttpOnly, Secure and SameSite expect: no token in mobile logs or plain app files
Every rule MATT holds →What the fix looks like
- 01
Keep web session tokens in HttpOnly, Secure, SameSite cookies.
- 02
Use the platform keystore or keychain for tokens on mobile.
- 03
Keep access tokens short‑lived and rotate refresh tokens on each use.
- 04
Remove token values from all logging, including debug builds.
A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →