CWE-266 Base Borrador

Incorrect Privilege Assignment

This vulnerability occurs when a system mistakenly grants a user, process, or entity a specific permission or privilege they should not have. This error creates an unintended level of access,…

Definición

What is CWE-266?

This vulnerability occurs when a system mistakenly grants a user, process, or entity a specific permission or privilege they should not have. This error creates an unintended level of access, allowing the actor to perform actions beyond their intended authority.
Incorrect privilege assignment is a core authorization flaw where the system's security model fails to properly enforce the principle of least privilege. Instead of granting the minimum access necessary for a function, the system erroneously provides elevated rights—such as administrative capabilities, write access to sensitive files, or the ability to modify other users' data. This mistake often stems from misconfigured access control lists (ACLs), flawed role-based access control (RBAC) logic, or errors during user/role provisioning. From a developer's perspective, this vulnerability is frequently introduced during code deployment or user management, rather than within the core application logic itself. Common scenarios include copying permission sets from high-privilege accounts, incorrectly mapping users to roles, or failing to validate inherited permissions. To prevent this, always implement explicit privilege assignment, audit permission changes, and use automated tools to verify that access controls match the intended security policy before deployment.
Impacto en el mundo real

Real-world CVEs caused by CWE-266

  • untrusted user placed in unix "wheel" group

  • Product allows users to grant themselves certain rights that can be used to escalate privileges.

  • Product uses group ID of a user instead of the group, causing it to run with different privileges. This is resultant from some other unknown issue.

  • Product mistakenly assigns a particular status to an entity, leading to increased privileges.

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  1. 1

    The following example demonstrates the weakness.

  2. 2

    The following example demonstrates the weakness.

  3. 3

    This application sends a special intent with a flag that allows the receiving application to read a data file for backup purposes.

  4. 4

    Any malicious application can register to receive this intent. Because of the FLAG_GRANT_READ_URI_PERMISSION included with the intent, the malicious receiver code can read the user's data.

Ejemplo de código vulnerable

Vulnerable C

The following example demonstrates the weakness.

Vulnerable C
seteuid(0);
```
/* do some stuff */* 
  
  seteuid(getuid());
Payload del atacante
Payload del atacante Java
public class CallReceiver extends BroadcastReceiver {
  	@Override
  	public void onReceive(Context context, Intent intent) {
  		Uri userData = intent.getData();
  		stealUserData(userData);
  	}
  }
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-266

  • Architecture and Design / Operation Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software.
  • Architecture and Design / Operation Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
Señales de detección

How to detect CWE-266

SAST High

Ejecuta análisis estático (SAST) sobre el código buscando el patrón inseguro en el flujo de datos.

DAST Moderate

Ejecuta pruebas dinámicas de seguridad de aplicaciones (DAST) contra el endpoint en vivo.

Runtime Moderate

Vigila los logs en tiempo de ejecución para detectar trazas de excepción inusuales, entradas malformadas o intentos de bypass de autorización.

Code review Moderate

Revisión de código: marca cualquier código nuevo que maneje entrada desde esta superficie sin usar los helpers validados del framework.

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-266 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-266?

This vulnerability occurs when a system mistakenly grants a user, process, or entity a specific permission or privilege they should not have. This error creates an unintended level of access, allowing the actor to perform actions beyond their intended authority.

¿Qué gravedad tiene CWE-266?

MITRE no ha publicado una calificación de probabilidad de explotación para esta debilidad. Trátala como de impacto medio hasta que tu modelo de amenazas demuestre lo contrario.

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

MITRE no ha especificado plataformas afectadas para esta CWE — puede aplicar a la mayoría de los stacks de aplicaciones.

¿Cómo puedo prevenir CWE-266?

Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software. Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need…

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

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-266 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-266?

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

Debilidades relacionadas

Weaknesses related to CWE-266

CWE-269 Padre

Improper Privilege Management

This vulnerability occurs when an application fails to correctly manage user permissions, allowing someone to perform actions or access…

CWE-250 Hermano

Execution with Unnecessary Privileges

This vulnerability occurs when software runs with higher permissions than it actually needs to perform its tasks. This excessive privilege…

CWE-267 Hermano

Privilege Defined With Unsafe Actions

This vulnerability occurs when a system grants a user, role, or process a specific permission that can be misused to perform dangerous,…

CWE-268 Hermano

Privilege Chaining

Privilege chaining occurs when an attacker combines two separate permissions or capabilities, neither of which is dangerous on its own, to…

CWE-270 Hermano

Privilege Context Switching Error

This vulnerability occurs when an application fails to properly manage user permissions while moving between different security contexts,…

CWE-271 Hermano

Privilege Dropping / Lowering Errors

This vulnerability occurs when a system or process fails to reduce its elevated permissions before transferring control of a resource to a…

CWE-274 Hermano

Improper Handling of Insufficient Privileges

This vulnerability occurs when an application fails to properly manage situations where it lacks the necessary permissions to execute an…

CWE-648 Hermano

Incorrect Use of Privileged APIs

This vulnerability occurs when software incorrectly uses functions that require special permissions. Attackers can exploit these mistakes…

CWE-286 Par

Incorrect User Management

This vulnerability occurs when an application incorrectly handles user accounts, roles, or group memberships, leading to improper access…

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.