Base · Medium

CWE-273: Improper Check for Dropped Privileges

The product attempts to drop privileges but does not check or incorrectly checks to see if the drop succeeded.

CWE-273 · Base Level ·2 CVEs ·3 Mitigations

Description

The product attempts to drop privileges but does not check or incorrectly checks to see if the drop succeeded.

If the drop fails, the product will continue to run with the raised privileges, which might provide additional access to unprivileged users.

Potential Impact

Access Control

Gain Privileges or Assume Identity

Access Control, Non-Repudiation

Gain Privileges or Assume Identity, Hide Activities

Demonstrative Examples

This code attempts to take on the privileges of a user before creating a file, thus avoiding performing the action with unnecessarily high privileges:
Bad
bool DoSecureStuff(HANDLE hPipe) {bool fDataWritten = false;ImpersonateNamedPipeClient(hPipe);HANDLE hFile = CreateFile(...);/../RevertToSelf()/../}
The call to ImpersonateNamedPipeClient may fail, but the return value is not checked. If the call fails, the code may execute with higher privileges than intended. In this case, an attacker could exploit this behavior to write a file to a location that the attacker does not have access to.

Mitigations & Prevention

Architecture and Design

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

Implementation High

Check the results of all functions that return a value and verify that the value is expected.

Implementation

In Windows, make sure that the process token has the SeImpersonatePrivilege(Microsoft Server 2003). Code that relies on impersonation for security must ensure that the impersonation succeeded, i.e., that a proper privilege demotion happened.

Detection Methods

  • Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea

Real-World CVE Examples

CVE IDDescription
CVE-2006-4447Program does not check return value when invoking functions to drop privileges, which could leave users with higher privileges than expected by forcing those functions to fail.
CVE-2006-2916Program does not check return value when invoking functions to drop privileges, which could leave users with higher privileges than expected by forcing those functions to fail.

Taxonomy Mappings

  • CLASP: — Failure to check whether privileges were dropped successfully
  • CERT C Secure Coding: POS37-C — Ensure that privilege relinquishment is successful
  • Software Fault Patterns: SFP4 — Unchecked Status Condition

Frequently Asked Questions

What is CWE-273?

CWE-273 (Improper Check for Dropped Privileges) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product attempts to drop privileges but does not check or incorrectly checks to see if the drop succeeded.

How can CWE-273 be exploited?

Attackers can exploit CWE-273 (Improper Check for Dropped Privileges) to gain privileges or assume identity. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-273?

Key mitigations include: 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 interfaci

What is the severity of CWE-273?

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