CWE-522: Weakly protected credentials | Causes and Fixes Skip to content

Security weakness

CWE-522 Weakly protected credentials

Passwords or login tokens are stored or sent in a way that lets someone else capture and reuse them.

  • Senior security engineers
  • 540+ projects delivered
  • Reply within one business day

Quick answer

What is CWE-522?

Insufficiently Protected Credentials: The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.

Business impact

What CWE-522 could cost your business

MITRE documents what this weakness can do. Here is what that means for a website, store or app.

Access Control

Accounts and admin areas exposed

Logins and permission checks can be bypassed, putting admin and customer accounts at risk.

  • Gain Privileges or Assume Identity

In plain English

What Weakly protected credentials means for your business

  • 540+projects delivered
  • 9+years in business
  • 23+certified experts
Get a free security check

A senior engineer replies within one business day.

Credentials are the things that prove identity: passwords, API keys, session tokens and recovery codes. Your site has to store them and move them between browser, server and other services. This weakness means that handling is not safe enough. Passwords may be saved in readable form or with weak scrambling, sent over an unencrypted connection, written into log files or emailed to users in plain text.

The business risk is account takeover at scale. If a database copy, backup or log file is exposed, poorly protected passwords can be read or recovered and then used to sign in. Because many people reuse passwords, the damage spreads to their accounts on other services, and your company is seen as the source. Good protection means a stolen copy of your data does not hand over working logins.

Where it shows up

  • Custom user tables that store passwords in plain text, with reversible encryption or with fast, outdated hashes such as MD5 or SHA-1.
  • Signup and password reset emails that send the actual password to the user, which shows it is stored or handled in readable form.
  • Application, server and analytics logs that record login requests in full, capturing passwords, tokens or API keys alongside ordinary traffic data.
  • Session tokens and API keys kept in browser local storage or cookies without Secure and HttpOnly flags, where scripts or network observers can read them.

Free security check

Is CWE-522 hiding in your site?

A senior engineer checks your site, store or app for this weakness and the rest of the CWE Top 25, then sends a prioritized fix plan within one business day. No obligation.

Official definition

How MITRE defines CWE-522

Insufficiently Protected Credentials

The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.

Weakness ID
CWE-522
Type
Class
Status
Incomplete
Applies to
Web Based, ICS/OT
Introduced during
Architecture and Design, Implementation

Fix it

How to fix Weakly protected credentials

Practical steps in priority order. Share them with your developer or agency.

  1. Hash passwords with a slow algorithm

    Store passwords only as salted hashes produced by a purpose-built function such as Argon2id, bcrypt or scrypt. Use your framework’s password API, and upgrade old hashes when each user next signs in.

  2. Encrypt credentials in transit

    Serve every page and API over HTTPS with current TLS, redirect HTTP to HTTPS and enable HSTS. Use encrypted connections between your application, database, cache and third-party services as well.

  3. Keep secrets out of logs and URLs

    Send credentials in request bodies or headers, never in query strings. Filter password, token and key fields from application logs, error trackers and analytics, and purge any old logs that already contain them.

  4. Protect tokens in the browser

    Keep session tokens in cookies marked Secure, HttpOnly and SameSite instead of script-readable storage. Give tokens a short lifetime, rotate them at login, and invalidate them on logout and password change.

  5. Store service credentials in a vault

    Hold API keys and database passwords in a secrets manager or encrypted configuration with tightly limited access. Show keys you issue to users only once at creation, and store a hash for later comparison.

Signs you may be affected

  • Your site can email users their existing password instead of a reset link.
  • Staff or support tools can view customer passwords or full API keys.
  • Passwords, tokens or keys are visible in log files, error reports or page addresses.

Questions to ask your developer

  • Which algorithm do we use to hash customer passwords?
  • Could anyone on the team, or any tool, read a user’s password?
  • Do our logs, error reports or URLs ever contain passwords or tokens?

Prevention

What MITRE recommends, phase by phase

Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.

  1. 01

    Architecture and Design

    • Use an appropriate security mechanism to protect the credentials.
    • Make appropriate use of cryptography to protect the credentials.
  2. 02

    Implementation

    • Use industry standards to protect the credentials (e.g. LDAP, keystore, etc.).

Detection and evidence

How CWE-522 is found, and where it has hit

The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.

How it is detected

  • Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then.

Real vulnerabilities it caused

  • CVE-2022-30018A messaging platform serializes all elements of User/Group objects, making private information available to adversaries
  • CVE-2022-29959Initialization file contains credentials that can be decoded using a "simple string transformation"
  • CVE-2022-35411Python-based RPC framework enables pickle functionality by default, allowing clients to unpickle untrusted data.
  • CVE-2022-29519Programmable Logic Controller (PLC) sends sensitive information in plaintext, including passwords and session tokens.
  • CVE-2022-30312Building Controller uses a protocol that transmits authentication credentials in plaintext.
  • CVE-2022-31204Programmable Logic Controller (PLC) sends password in plaintext.

How we fix it

From finding to fixed: how Codefreex closes CWE-522

  1. Scan and confirm

    We test your site, store or app for this weakness and the rest of the CWE Top 25 with automated scanning and manual review, and confirm what is actually exploitable.

  2. Fix at the source

    We change the code, configuration or dependency that causes it, not just the symptom, and plan the changes to avoid downtime.

  3. Verify the fix

    We retest every finding, check that nothing else broke and hand you a short report you can share with your team, client or auditor.

  4. Keep it fixed

    Updates, monitoring and maintenance so the weakness does not return with the next plugin, theme, app or code change.

FAQ

CWE-522: FAQs

Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.

How serious is weak credential protection?

It turns a contained incident into a much larger one. If attackers obtain a database copy or log file and the passwords inside are readable or easily recovered, every affected account is at risk, on your site and anywhere those passwords are reused. That can bring notification duties, forced resets, support load and lasting damage to customer trust.

How do I prevent credential exposure?

Never store a password you could read back. Hash passwords with Argon2id, bcrypt or scrypt through your framework’s built-in functions. Use HTTPS everywhere. Keep credentials out of logs, URLs and emails. Store API keys and database passwords in a secrets manager, and limit who and what can access them.

What is the difference between hashing and encrypting passwords?

Encryption is reversible: anyone with the key can turn the stored value back into the password. Hashing is one-way: the site stores a fingerprint and compares it at login, so the original password is never kept. Passwords should be hashed with a slow, salted algorithm designed for the purpose. Encryption suits secrets your system must read again, such as API keys.

What is CWE-522?

CWE-522, “Insufficiently Protected Credentials”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.

How serious is CWE-522?

It can affect access control, with impacts such as gain privileges or assume identity. The real risk depends on where the weakness sits and what data or functions it exposes.

How do you prevent CWE-522?

Use an appropriate security mechanism to protect the credentials. Make appropriate use of cryptography to protect the credentials.

Can Codefreex check my site for CWE-522?

Yes. A senior engineer reviews your site, store or app for CWE-522 and the rest of the CWE Top 25, confirms what is exploitable and sends a prioritized fix plan within one business day. Start with the free security check form on this page.

Free security check

Find out if CWE-522 affects your site

Send your URL. A senior engineer checks for this weakness and the rest of the CWE Top 25, and replies within one business day with what to fix first.

  • A senior strategist reviews your request, not a sales bot
  • Clear scope, timeline and estimate within one business day
  • Free 30-minute discovery call, no obligation
  • NDA available on request

Weakness data from the Common Weakness Enumeration (CWE®) version 5.0, Copyright © 2006–2026, The MITRE Corporation. CWE is free to use by any organization or individual for any research, development, and/or commercial purposes under the CWE Terms of Use. CWE is a registered trademark of The MITRE Corporation. The business impact, risk profile and plain-English guidance on this page are written by Codefreex and are general information, not a security assessment of your system.