CWE-287 Clase Borrador 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.

Definición

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.
Impacto en el mundo real

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.

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  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.

Ejemplo de código vulnerable

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.

Vulnerable 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();
  }
Payload del atacante

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:

Payload del atacante
GET /cgi-bin/vulnerable.cgi HTTP/1.1
  Cookie: user=Administrator
  Cookie: loggedin=true
  [body of request]
Ejemplo de código seguro

Secure pseudo

Seguro 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.
Lista de prevención

How to prevent CWE-287

  • Architecture and Design Use an authentication framework or library such as the OWASP ESAPI Authentication feature.
Señales de detección

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)

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-287 y abre un PR de corrección en menos de 60 segundos.

Codex Remedium escanea cada commit, identifica esta debilidad concreta y entrega un pull request listo para revisión con el parche. Sin tickets. Sin traspasos.

Preguntas frecuentes

Frequently asked questions

¿Qué es 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.

¿Qué gravedad tiene CWE-287?

MITRE califica la probabilidad de explotación como Alta — esta debilidad se explota activamente en la práctica y debe priorizarse para su remediación.

¿Qué lenguajes o plataformas se ven afectados por CWE-287?

MITRE lists the following affected platforms: ICS/OT.

¿Cómo puedo prevenir CWE-287?

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

¿Cómo detecta y corrige Plexicus CWE-287?

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-287 en cada commit. Cuando hay coincidencia, nuestro agente Codex Remedium abre un PR de corrección con el código corregido, las pruebas y un resumen de una línea para el revisor.

¿Dónde puedo aprender más sobre CWE-287?

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/287.html. También puedes consultar la documentación de OWASP y NIST para guías relacionadas.

Debilidades relacionadas

Weaknesses related to CWE-287

CWE-284 Padre

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 Hermano

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 Hermano

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 Hermano

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 Hermano

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 Hermano

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 Hermano

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 Hermano

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 Hermano

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…

Listo cuando tú lo estés

Deja de pagar por desarrollador.
Empieza a cerrar el bucle.

Plexicus es el ASPM nativo de IA que escanea, filtra, corrige, pentestea y explica — de forma autónoma. Desarrolladores ilimitados, repos ilimitados, acciones de IA de uso justo. Nivel gratuito real, €269/mo anual cuando estés listo.