CWE-922Data exposureSeverity · Medium

Tokens stored where other code can read them

Access tokens kept in browser storage or device logs, where other scripts and apps can read them. One stolen token lets someone act as the user.

At a glance

Controls
CWE-922 · A01:2021 Broken Access Control
Typical severityMedium
ReferenceCWE-922
OWASP Top 10A01: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.

  1. 01Read the front-end and mobile code to find where tokens are saved after sign-in.
  2. 02Sign in as a test user and inspect browser storage, cookies and device logs for the token.
  3. 03Show that page script can read the token, using only the tester's own session.
The rule, in plain English

Tokens must be stored only in protected storage.

Executable check

as 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

  1. 01

    Keep web session tokens in HttpOnly, Secure, SameSite cookies.

  2. 02

    Use the platform keystore or keychain for tokens on mobile.

  3. 03

    Keep access tokens short‑lived and rotate refresh tokens on each use.

  4. 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? →

ExploitOps discovery call

Understand where your security loop breaks.

A call with a MATT co-founder to understand your product and whether an ExploitOps Review is worth doing. If there is a real need, we scope one with the research team.

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02