Description
The elevated privilege level required to perform operations such as chroot() should be dropped immediately after the operation is performed.
Potential Impact
Access Control, Confidentiality
Gain Privileges or Assume Identity, Read Application Data, Read Files or Directories
Demonstrative Examples
setuid(0);
// Do some important stuff
setuid(old_uid);
// Do some non privileged stuff.AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// privileged code goes here, for example:
System.loadLibrary("awt");return null;
// nothing to return
}chroot(APP_HOME);chdir("/");FILE* data = fopen(argv[1], "r+");...Mitigations & Prevention
Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software.
Follow the principle of least privilege when assigning access rights to entities in a software system.
Compartmentalize the system to have "safe" areas where trust boundaries can be unambiguously drawn. Do not allow sensitive data to go outside of the trust boundary and always be careful when interfacing with a compartment outside of the safe area. Ensure that appropriate compartmentalization is built into the system design, and the compartmentalization allows for and reinforces privilege separation functionality. Architects and designers should rely on the principle of least
Detection Methods
- Automated Static Analysis - Binary or Bytecode SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
- Dynamic Analysis with Automated Results Interpretation SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
- Manual Static Analysis - Source Code High — According to SOAR [REF-1479], the following detection techniques may be useful:
- Automated Static Analysis - Source Code SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
- Automated Static Analysis SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
- Architecture or Design Review High — According to SOAR [REF-1479], the following detection techniques may be useful:
Related Weaknesses
Taxonomy Mappings
- 7 Pernicious Kingdoms: — Least Privilege Violation
- CLASP: — Failure to drop privileges when reasonable
- CERT C Secure Coding: POS02-C — Follow the principle of least privilege
- 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
- Software Fault Patterns: SFP36 — Privilege
Frequently Asked Questions
What is CWE-272?
CWE-272 (Least Privilege Violation) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The elevated privilege level required to perform operations such as chroot() should be dropped immediately after the operation is performed.
How can CWE-272 be exploited?
Attackers can exploit CWE-272 (Least Privilege Violation) to gain privileges or assume identity, read application data, read files or directories. This weakness is typically introduced during the Implementation, Operation phase of software development.
How do I prevent CWE-272?
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-272?
CWE-272 is classified as a Base-level weakness (Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.