CWE-287 Classe Brouillon High likelihood

Improper Authentication

Improper Authentication occurs when a system fails to properly verify a user's claimed identity, allowing access without sufficient proof of who they are.

Définition

What is CWE-287?

Improper Authentication occurs when a system fails to properly verify a user's claimed identity, allowing access without sufficient proof of who they are.
This vulnerability happens when an application doesn't implement strong enough checks to confirm a user is who they say they are. Attackers can exploit weak or missing authentication to impersonate legitimate users, gain unauthorized access, and steal sensitive data or perform privileged actions. Common causes include skipping authentication entirely, using weak credential checks, or accidentally leaving debug backdoors active. To prevent this, developers must implement robust, standardized authentication mechanisms for all access points. This includes using strong password policies, multi-factor authentication (MFA), secure session management, and ensuring authentication logic cannot be bypassed. Always validate credentials against a trusted authority and treat any unauthenticated request as originating from an anonymous, untrusted user.
Vulnerability Diagram CWE-287
Improper Authentication Login user="admin" pw="" Auth check if (pw == storedPw) ok storedPw absent → null=="" → true (loose equality) no proper validation Session granted as admin Authentication logic accepts inputs it should reject.
Impact réel

Real-world CVEs caused by CWE-287

  • File-sharing PHP product does not check if user is logged in during requests for PHP library files under an includes/ directory, allowing configuration changes, code execution, and other impacts.

  • Chat application skips validation when Central Authentication Service (CAS) is enabled, effectively removing the second factor from two-factor authentication

  • Python-based authentication proxy does not enforce password authentication during the initial handshake, allowing the client to bypass authentication by specifying a 'None' authentication type.

  • Chain: Web UI for a Python RPC framework does not use regex anchors to validate user login emails (CWE-777), potentially allowing bypass of OAuth (CWE-1390).

  • TCP-based protocol in Programmable Logic Controller (PLC) has no authentication.

  • Condition Monitor uses a protocol that does not require authentication.

  • Safety Instrumented System uses proprietary TCP protocols with no authentication.

  • Distributed Control System (DCS) uses a protocol that has no authentication.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    The following code intends to ensure that the user is already logged in. If not, the code performs authentication with the user-provided username and password. If successful, it sets the loggedin and user cookies to "remember" that the user has already logged in. Finally, the code performs administrator tasks if the logged-in user has the "Administrator" username, as recorded in the user cookie.

  2. 2

    Unfortunately, this code can be bypassed. The attacker can set the cookies independently so that the code does not check the username and password. The attacker could do this with an HTTP request containing headers such as:

  3. 3

    By setting the loggedin cookie to "true", the attacker bypasses the entire authentication check. By using the "Administrator" value in the user cookie, the attacker also gains privileges to administer the software.

  4. 4

    In January 2009, an attacker was able to gain administrator access to a Twitter server because the server did not restrict the number of login attempts [REF-236]. The attacker targeted a member of Twitter's support team and was able to successfully guess the member's password using a brute force attack by guessing a large number of common words. After gaining access as the member of the support staff, the attacker used the administrator panel to gain access to 33 accounts that belonged to celebrities and politicians. Ultimately, fake Twitter messages were sent that appeared to come from the compromised accounts.

  5. 5

    In 2022, the OT:ICEFALL study examined products by 10 different Operational Technology (OT) vendors. The researchers reported 56 vulnerabilities and said that the products were "insecure by design" [REF-1283]. If exploited, these vulnerabilities often allowed adversaries to change how the products operated, ranging from denial of service to changing the code that the products executed. Since these products were often used in industries such as power, electrical, water, and others, there could even be safety implications.

Exemple de code vulnérable

Vulnerable Perl

The following code intends to ensure that the user is already logged in. If not, the code performs authentication with the user-provided username and password. If successful, it sets the loggedin and user cookies to "remember" that the user has already logged in. Finally, the code performs administrator tasks if the logged-in user has the "Administrator" username, as recorded in the user cookie.

Vulnérable Perl
my $q = new CGI;
  if ($q->cookie('loggedin') ne "true") {
  		if (! AuthenticateUser($q->param('username'), $q->param('password'))) {
  			ExitError("Error: you need to log in first");
  		}
  		else {
  				# Set loggedin and user cookies.
  				$q->cookie(
  					-name => 'loggedin',
  					-value => 'true'
  					);
  				$q->cookie(
  					-name => 'user',
  					-value => $q->param('username')
  					);
  		}
  }
  if ($q->cookie('user') eq "Administrator") {
  	DoAdministratorTasks();
  }
Charge utile de l'attaquant

Unfortunately, this code can be bypassed. The attacker can set the cookies independently so that the code does not check the username and password. The attacker could do this with an HTTP request containing headers such as:

Charge utile de l'attaquant
GET /cgi-bin/vulnerable.cgi HTTP/1.1
  Cookie: user=Administrator
  Cookie: loggedin=true
  [body of request]
Exemple de code sécurisé

Secure pseudo

Sécurisé 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.
Liste de contrôle de prévention

How to prevent CWE-287

  • Architecture and Design Use an authentication framework or library such as the OWASP ESAPI Authentication feature.
Signaux de détection

How to detect CWE-287

Automated Static Analysis Limited

Automated static analysis is useful for detecting certain types of authentication. A tool may be able to analyze related configuration files, such as .htaccess in Apache web servers, or detect the usage of commonly-used authentication libraries. Generally, automated static analysis tools have difficulty detecting custom authentication schemes. In addition, the software's design may include some functionality that is accessible to any user and does not require an established identity; an automated technique that detects the absence of authentication may report false positives.

Manual Static Analysis High

This weakness can be detected using tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. Manual static analysis is useful for evaluating the correctness of custom authentication mechanisms.

Manual Static Analysis - Binary or Bytecode SOAR Partial

According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies

Dynamic Analysis with Automated Results Interpretation SOAR Partial

According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Web Application Scanner Web Services Scanner Database Scanners

Dynamic Analysis with Manual Results Interpretation SOAR Partial

According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Fuzz Tester Framework-based Fuzzer

Manual Static Analysis - Source Code SOAR Partial

According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Manual Source Code Review (not inspections)

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-287 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-287 ?

Improper Authentication occurs when a system fails to properly verify a user's claimed identity, allowing access without sufficient proof of who they are.

Quelle est la gravité de CWE-287 ?

MITRE évalue la probabilité d'exploitation comme Élevée — cette faiblesse est activement exploitée et doit être priorisée pour la remédiation.

Quels langages ou plateformes sont affectés par CWE-287 ?

MITRE lists the following affected platforms: ICS/OT.

Comment puis-je prévenir CWE-287 ?

Use an authentication framework or library such as the OWASP ESAPI Authentication feature.

Comment Plexicus détecte et corrige CWE-287 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-287 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-287 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/287.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Faiblesses associées

Weaknesses related to CWE-287

CWE-284 Parent

Improper Access Control

The software fails to properly limit who can access a resource, allowing unauthorized users or systems to interact with it.

CWE-1191 Frère

On-Chip Debug and Test Interface With Improper Access Control

This vulnerability occurs when a hardware chip's debug or test interface (like JTAG) lacks proper access controls. Without correct…

CWE-1220 Frère

Insufficient Granularity of Access Control

This vulnerability occurs when a system's access controls are too broad, allowing unauthorized users or processes to read or modify…

CWE-1224 Frère

Improper Restriction of Write-Once Bit Fields

This vulnerability occurs when hardware write-once protection mechanisms, often called 'sticky bits,' are incorrectly implemented,…

CWE-1231 Frère

Improper Prevention of Lock Bit Modification

This vulnerability occurs when hardware or firmware uses a lock bit to protect critical system registers or memory regions, but fails to…

CWE-1233 Frère

Security-Sensitive Hardware Controls with Missing Lock Bit Protection

This vulnerability occurs when a hardware device uses a lock bit to protect critical configuration registers, but the lock fails to…

CWE-1252 Frère

CPU Hardware Not Configured to Support Exclusivity of Write and Execute Operations

This vulnerability occurs when a CPU's hardware is not set up to enforce a strict separation between writing data to memory and executing…

CWE-1257 Frère

Improper Access Control Applied to Mirrored or Aliased Memory Regions

This vulnerability occurs when a hardware design maps the same physical memory to multiple addresses (aliasing or mirroring) but fails to…

CWE-1259 Frère

Improper Restriction of Security Token Assignment

This vulnerability occurs when a System-on-a-Chip (SoC) fails to properly secure its Security Token mechanism. These tokens control which…

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.