CWE-266 Base Brouillon

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,…

Définition

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.
Impact réel

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.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  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.

Exemple de code vulnérable

Vulnerable C

The following example demonstrates the weakness.

Vulnérable C
seteuid(0);
```
/* do some stuff */* 
  
  seteuid(getuid());
Charge utile de l'attaquant
Charge utile de l'attaquant Java
public class CallReceiver extends BroadcastReceiver {
  	@Override
  	public void onReceive(Context context, Intent intent) {
  		Uri userData = intent.getData();
  		stealUserData(userData);
  	}
  }
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-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.
Signaux de détection

How to detect CWE-266

SAST High

Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.

DAST Moderate

Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.

Runtime Moderate

Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.

Code review Moderate

Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-266 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-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.

Quelle est la gravité de CWE-266 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

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

MITRE n'a pas spécifié les plateformes affectées pour ce CWE — il peut s'appliquer à la plupart des stacks applicatives.

Comment puis-je prévenir 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…

Comment Plexicus détecte et corrige CWE-266 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-266 à 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-266 ?

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

Faiblesses associées

Weaknesses related to CWE-266

CWE-269 Parent

Improper Privilege Management

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

CWE-250 Frère

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 Frère

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 Frère

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 Frère

Privilege Context Switching Error

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

CWE-271 Frère

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 Frère

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 Frère

Incorrect Use of Privileged APIs

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

CWE-286 Pair

Incorrect User Management

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

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.