CWE-922OWASP A02:2021OWASP API8:2023CWE-312

CWE-922: Insecure Storage of Sensitive Information

Sensitive information is stored without adequate protection, such as plaintext passwords or unencrypted personal data, so a single access leaks it.

Also known as: Plaintext storage, Unencrypted sensitive data, Weak data-at-rest protection

Risk

Usually high. When secrets or personal data sit in plaintext, one database read, backup leak, or stolen browser store exposes everything at once with no further effort.

Definition

What it is

CWE-922 is storing sensitive information without the protection it needs. Common forms are passwords saved in plaintext or with a fast, unsalted hash, API keys and personal data kept unencrypted in a database, and tokens or secrets placed in browser localStorage. The weakness turns any single point of access, a leaked backup, a SQL injection, a shared device, into full disclosure. Protection must match the data: passwords need a slow salted hash, and other secrets need encryption at rest with controlled keys.

Use-cases

How it shows up in real code

Plaintext passwords

User passwords are stored as written, or with a plain fast hash. One database leak hands every account's password straight to the attacker.

Unencrypted secrets in the database

Third-party API keys and tokens are saved as plaintext columns. Any read of that table, including through injection, exposes all of them.

Token in localStorage

A session or API token is kept in browser localStorage. Any cross-site-scripting flaw reads it, and it also persists on shared machines.

PII with no encryption

Personal data is stored unencrypted, so a backup copied to an insecure location discloses everyone's records in full.

AI risk

Why AI-generated code has increased the exposure

  • Assistants optimize for a working save-and-read flow, and storing a value verbatim is the simplest way to make it readable again, so plaintext is the default.
  • Training data includes many examples that store passwords with a fast hash or none, so the model reproduces weak password storage.
  • The model cannot see the deployment's key management or encryption layer, so it writes secrets as plain columns rather than wiring in encryption.
  • Asked to persist a token in the browser, the assistant reaches for localStorage because it is the most common example, exposing it to scripts.
  • Across the many storage sites generated code creates, each unprotected write adds another place sensitive data sits in the clear.

Vibe coding

How vibe coding amplifies the risk

  • Vibe coding ships whatever storage the assistant chose, and plaintext that saves and loads correctly looks like it works.
  • The skipped review is where someone would ask is this password hashed properly and is this secret encrypted at rest.
  • A prototype that stored secrets in plaintext for speed is promoted to production carrying all of them unprotected.
  • The weakness is invisible in local and demo testing because the app reads its own data fine; nobody simulates a stolen database or backup.
  • As a vibe-coded product accumulates users and data, the unencrypted store grows into a single breach that exposes everything at once.

Detection

How to find it

  • Check how passwords are stored and confirm a slow salted algorithm such as bcrypt, scrypt, or Argon2, not plaintext or a fast hash.
  • Inspect the schema for secrets and personal data kept in plaintext columns that should be encrypted at rest.
  • Look for tokens or sensitive values written to browser localStorage or other script-readable client storage.
  • Review backups and exports to confirm sensitive data is not stored or copied unprotected.

Remediation

How to fix it

  • Hash passwords with a slow salted algorithm such as Argon2, bcrypt, or scrypt, and never store them reversibly.
  • Encrypt sensitive data at rest with keys held in a secrets manager or KMS, not alongside the data.
  • Keep session and API tokens out of localStorage; prefer secure, HttpOnly cookies for session tokens.
  • Minimize what you store: avoid keeping secrets and personal data you do not need, and set retention limits.
  • Protect backups and exports with the same encryption and access controls as the live store.

Frequently asked questions

What is CWE-922 (insecure storage of sensitive information)?
CWE-922 is storing sensitive information without adequate protection, such as plaintext or weakly hashed passwords, unencrypted secrets and personal data, or tokens in browser localStorage. It turns a single access, like a leaked backup or an injection, into full disclosure of the data.
How have AI assistants and vibe coding increased the risk?
Assistants optimize for a save-and-read flow that works, and storing values verbatim or with a fast hash is simplest, so they default to plaintext and reach for localStorage for tokens. Vibe coding ships that storage because it reads back fine in testing, and nobody simulates a stolen database, so the unprotected data reaches production.
How do I fix insecure storage of sensitive information?
Hash passwords with a slow salted algorithm, encrypt other sensitive data at rest with keys held in a KMS, keep tokens out of localStorage in favor of secure HttpOnly cookies, store only what you need, and protect backups with the same controls.

Related weaknesses

Catch CWE-922 before you ship

Tethlyn Audit scans your codebase and its git history for CWE-922 and the rest of the sensitive data exposure & privacy class, then ranks each finding by real exploitability and data sensitivity.

See Tethlyn Audit