CWE-272 最小特权原则违背
Least Privilege Violation
结构: Simple
Abstraction: Base
状态: Incomplete
被利用可能性: unkown
基本描述
The elevated privilege level required to perform operations such as chroot() should be dropped immediately after the operation is performed.
相关缺陷
-
cwe_Nature: ChildOf cwe_CWE_ID: 271 cwe_View_ID: 1000 cwe_Ordinal: Primary
-
cwe_Nature: ChildOf cwe_CWE_ID: 271 cwe_View_ID: 699 cwe_Ordinal: Primary
适用平台
Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}
常见的影响
范围 | 影响 | 注释 |
---|---|---|
['Access Control', 'Confidentiality'] | ['Gain Privileges or Assume Identity', 'Read Application Data', 'Read Files or Directories'] | An attacker may be able to access resources with the elevated privilege that could not be accessed with the attacker's original privileges. This is particularly likely in conjunction with another flaw, such as a buffer overflow. |
检测方法
Automated Static Analysis - Binary or Bytecode
According to SOAR, the following detection techniques may be useful:
- Compare binary / bytecode to application permission manifest
Dynamic Analysis with Automated Results Interpretation
According to SOAR, the following detection techniques may be useful:
- Host-based Vulnerability Scanners – Examine configuration for flaws, verifying that audit mechanisms work, ensure host configuration meets certain predefined criteria
Manual Static Analysis - Source Code
According to SOAR, the following detection techniques may be useful:
- Manual Source Code Review (not inspections)
- Focused Manual Spotcheck - Focused manual analysis of source
Automated Static Analysis - Source Code
According to SOAR, the following detection techniques may be useful:
- Source code Weakness Analyzer
- Context-configured Source Code Weakness Analyzer
Automated Static Analysis
According to SOAR, the following detection techniques may be useful:
- Permission Manifest Analysis
Architecture or Design Review
According to SOAR, the following detection techniques may be useful:
- Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
- Formal Methods / Correct-By-Construction
- Attack Modeling
可能的缓解方案
MIT-1 ['Architecture and Design', 'Operation']
策略:
Very carefully manage the setting, management, and handling of privileges. Explicitly manage trust zones in the software.
MIT-48 Architecture and Design
策略: Separation of Privilege
Follow the principle of least privilege when assigning access rights to entities in a software system.
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.
示例代码
例
The following example demonstrates the weakness.
bad C
// Do some important stuff
setuid(old_uid);
// Do some non privileged stuff.
bad Java
// Insert all code here
}
};
}
例
The following code calls chroot() to restrict the application to a subset of the filesystem below APP_HOME in order to prevent an attacker from using the program to gain unauthorized access to files located elsewhere. The code then opens a file specified by the user and processes the contents of the file.
bad C
chdir("/");
FILE* data = fopen(argv[1], "r+");
...
Constraining the process inside the application's home directory before opening any files is a valuable security measure. However, the absence of a call to setuid() with some non-zero value means the application is continuing to operate with unnecessary root privileges. Any successful exploit carried out by an attacker against the application can now result in a privilege escalation attack because any malicious operations will be performed with the privileges of the superuser. If the application drops to the privilege level of a non-root user, the potential for damage is substantially reduced.
Notes
Maintenance
CWE-271, CWE-272, and CWE-250 are all closely related and possibly overlapping. CWE-271 is probably better suited as a category.
Other
分类映射
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
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 |
相关攻击模式
- CAPEC-17
- CAPEC-35
- CAPEC-76
文章来源于互联网:scap中文网
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论