Base · Medium

CWE-266: Incorrect Privilege Assignment

A product incorrectly assigns a privilege to a particular actor, creating an unintended sphere of control for that actor.

CWE-266 · Base Level ·4 CVEs ·2 Mitigations

Description

A product incorrectly assigns a privilege to a particular actor, creating an unintended sphere of control for that actor.

Potential Impact

Access Control

Gain Privileges or Assume Identity

Demonstrative Examples

The following example demonstrates the weakness.
Bad
seteuid(0);
                     /* do some stuff */
                     
                     seteuid(getuid());
The following example demonstrates the weakness.
Bad
AccessController.doPrivileged(new PrivilegedAction() {
                        public Object run() {
                                 // privileged code goes here, for example:
                                 System.loadLibrary("awt");return null;
                                 // nothing to return
                                 
                           }
This application sends a special intent with a flag that allows the receiving application to read a data file for backup purposes.
Bad
Intent intent = new Intent();intent.setAction("com.example.BackupUserData");intent.setData(file_uri);intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);sendBroadcast(intent);
Attack
public class CallReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {Uri userData = intent.getData();stealUserData(userData);}}
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.

Mitigations & Prevention

Architecture and DesignOperation

Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software.

Architecture and DesignOperation

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.

Real-World CVE Examples

CVE IDDescription
CVE-1999-1193untrusted user placed in unix "wheel" group
CVE-2005-2741Product allows users to grant themselves certain rights that can be used to escalate privileges.
CVE-2005-2496Product 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.
CVE-2004-0274Product mistakenly assigns a particular status to an entity, leading to increased privileges.

Taxonomy Mappings

  • PLOVER: — Incorrect Privilege Assignment
  • The CERT Oracle Secure Coding Standard for Java (2011): SEC00-J — Do not allow privileged blocks to leak sensitive information across a trust boundary
  • The CERT Oracle Secure Coding Standard for Java (2011): SEC01-J — Do not allow tainted variables in privileged blocks

Frequently Asked Questions

What is CWE-266?

CWE-266 (Incorrect Privilege Assignment) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. A product incorrectly assigns a privilege to a particular actor, creating an unintended sphere of control for that actor.

How can CWE-266 be exploited?

Attackers can exploit CWE-266 (Incorrect Privilege Assignment) to gain privileges or assume identity. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-266?

Key mitigations include: Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software.

What is the severity of CWE-266?

CWE-266 is classified as a Base-level weakness (Medium abstraction). It has been observed in 4 real-world CVEs.