CWE-273 对于放弃特权的检查不恰当

Improper Check for Dropped Privileges

结构: Simple

Abstraction: Base

状态: Incomplete

被利用可能性: Medium

基本描述

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

扩展描述

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

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 754 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 754 cwe_View_ID: 1003 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 271 cwe_View_ID: 1000

  • cwe_Nature: ChildOf cwe_CWE_ID: 271 cwe_View_ID: 699 cwe_Ordinal: Primary

  • cwe_Nature: PeerOf cwe_CWE_ID: 252 cwe_View_ID: 1000

适用平台

Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
Access Control Gain Privileges or Assume Identity If privileges are not dropped, neither are access rights of the user. Often these rights can be prevented from being dropped.
['Access Control', 'Non-Repudiation'] ['Gain Privileges or Assume Identity', 'Hide Activities'] If privileges are not dropped, in some cases the system may record actions as the user which is being impersonated rather than the impersonator.

可能的缓解方案

MIT-46 Architecture and Design

策略: Separation of Privilege

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 that the compartmentalization serves to allow for and further reinforce privilege separation functionality. Architects and designers should rely on the principle of least privilege to decide when it is appropriate to use and to drop system privileges.

MIT-53 Implementation

策略:

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.

示例代码

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 C++

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.

分析过的案例

标识 说明 链接
CVE-2006-4447 Program 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. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-4447
CVE-2006-2916 Program 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. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-2916

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
CLASP Failure to check whether privileges were dropped successfully
CERT C Secure Coding POS37-C Exact Ensure that privilege relinquishment is successful
Software Fault Patterns SFP4 Unchecked Status Condition