CWE-522 Class Incomplete

Insufficiently Protected Credentials

This vulnerability occurs when an application handles sensitive credentials like passwords or API keys in an insecure way, making them easy for attackers to steal during transmission or while stored.

Definition

What is CWE-522?

This vulnerability occurs when an application handles sensitive credentials like passwords or API keys in an insecure way, making them easy for attackers to steal during transmission or while stored.
Insufficiently protected credentials are a primary target for attackers. This happens when developers rely on weak or outdated methods, such as sending passwords in plain text over unencrypted connections (HTTP), storing them in easily accessible logs or public code repositories, or using weak encryption that can be easily reversed. Attackers exploit these flaws using simple network sniffing, searching public code commits, or accessing poorly secured databases to harvest credentials and gain unauthorized access. To prevent this, always enforce strong, modern security practices. This means using TLS (HTTPS) for all credential transmission, never logging or caching passwords, and employing robust, salted hashing algorithms (like Argon2 or bcrypt) for storage. Additionally, implement secure credential management solutions, such as secrets managers or environment variables, to keep keys out of your application code entirely. Regular security audits and automated scanning can help catch these dangerous oversights before they are exploited.
Auswirkungen in der Praxis

Real-world CVEs caused by CWE-522

  • A messaging platform serializes all elements of User/Group objects, making private information available to adversaries

  • Initialization file contains credentials that can be decoded using a "simple string transformation"

  • Python-based RPC framework enables pickle functionality by default, allowing clients to unpickle untrusted data.

  • Programmable Logic Controller (PLC) sends sensitive information in plaintext, including passwords and session tokens.

  • Building Controller uses a protocol that transmits authentication credentials in plaintext.

  • Programmable Logic Controller (PLC) sends password in plaintext.

  • Remote Terminal Unit (RTU) uses a driver that relies on a password stored in plaintext.

  • Web app allows remote attackers to change the passwords of arbitrary users without providing the original password, and possibly perform other unauthorized actions.

Wie Angreifer es ausnutzen

Angreiferpfad Schritt für Schritt

  1. 1

    This code changes a user's password.

  2. 2

    While the code confirms that the requesting user typed the same new password twice, it does not confirm that the user requesting the password change is the same user whose password will be changed. An attacker can request a change of another user's password and gain control of the victim's account.

  3. 3

    The following code reads a password from a properties file and uses the password to connect to a database.

  4. 4

    This code will run successfully, but anyone who has access to config.properties can read the value of password. If a devious employee has access to this information, they can use it to break into the system.

  5. 5

    The following code reads a password from the registry and uses the password to create a new network credential.

Verwundbares Codebeispiel

Vulnerable PHP

This code changes a user's password.

Verwundbar PHP
$user = $_GET['user'];
  $pass = $_GET['pass'];
  $checkpass = $_GET['checkpass'];
  if ($pass == $checkpass) {
  	SetUserPassword($user, $pass);
  }
Sicheres Codebeispiel

Secure pseudo

Sicher pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Präventions-Checkliste

How to prevent CWE-522

  • Architecture and Design Use an appropriate security mechanism to protect the credentials.
  • Architecture and Design Make appropriate use of cryptography to protect the credentials.
  • Implementation Use industry standards to protect the credentials (e.g. LDAP, keystore, etc.).
Erkennungssignale

How to detect CWE-522

Automated Static Analysis High

Automated 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 searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Plexicus Auto-Fix

Plexicus erkennt CWE-522 automatisch und öffnet in unter 60 Sekunden einen Fix-PR.

Codex Remedium scannt jeden Commit, identifiziert genau diese Schwachstelle und liefert einen reviewer-ready Pull Request mit dem Patch. Keine Tickets. Keine Hand-offs.

Häufig gestellte Fragen

Frequently asked questions

Was ist CWE-522?

This vulnerability occurs when an application handles sensitive credentials like passwords or API keys in an insecure way, making them easy for attackers to steal during transmission or while stored.

Wie gravierend ist CWE-522?

MITRE hat für diese Schwachstelle keine Exploit-Wahrscheinlichkeit veröffentlicht. Behandle sie als mittlere Auswirkung, bis dein Threat Model anderes belegt.

Welche Sprachen oder Plattformen sind von CWE-522 betroffen?

MITRE lists the following affected platforms: ICS/OT.

Wie kann ich CWE-522 verhindern?

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

Wie erkennt und behebt Plexicus CWE-522?

Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-522 bei jedem Commit. Bei einem Treffer öffnet unser Codex-Remedium-Agent einen Fix-PR mit korrigiertem Code, Tests und einer einzeiligen Zusammenfassung für den Reviewer.

Wo erfahre ich mehr über CWE-522?

MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/522.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.

Verwandte Schwachstellen

Weaknesses related to CWE-522

CWE-1390 Parent

Weak Authentication

This vulnerability occurs when a system's login or identity verification process is too easy to bypass or fool. While it attempts to check…

CWE-1391 Sibling

Use of Weak Credentials

This vulnerability occurs when a system relies on weak authentication credentials—like default passwords, hard-coded keys, or easily…

CWE-262 Sibling

Not Using Password Aging

This vulnerability occurs when a system lacks password expiration policies, allowing users to keep the same password indefinitely.

CWE-263 Sibling

Password Aging with Long Expiration

The system enforces password changes, but the time allowed between changes is excessively long, weakening security.

CWE-289 Sibling

Authentication Bypass by Alternate Name

This vulnerability occurs when a system checks access based on a resource or user name, but fails to account for all the different names…

CWE-290 Sibling

Authentication Bypass by Spoofing

This weakness occurs when an application's authentication system can be tricked into accepting forged or manipulated credentials, allowing…

CWE-294 Sibling

Authentication Bypass by Capture-replay

This vulnerability occurs when an attacker can intercept and record legitimate authentication traffic, then replay it later to gain…

CWE-301 Sibling

Reflection Attack in an Authentication Protocol

A reflection attack is a flaw in mutual authentication protocols that allows an attacker to impersonate a legitimate user without knowing…

CWE-302 Sibling

Authentication Bypass by Assumed-Immutable Data

This vulnerability occurs when an authentication system incorrectly treats certain data as unchangeable, when in fact an attacker can…

Bereit, wenn du es bist

Schluss mit dem Bezahlen pro Entwickler.
Schließ den Kreislauf.

Plexicus ist die KI-native ASPM, die scannt, filtert, fixt, pentestet und erklärt — autonom. Unbegrenzte Entwickler, unbegrenzte Repos, Fair-Use-KI-Aktionen. Echter kostenloser Tarif, €269/mo jährlich, wenn du bereit bist.