CWE-269 特权管理不恰当

admin 2021年12月16日16:17:00评论65 views字数 5941阅读19分48秒阅读模式

CWE-269 特权管理不恰当

Improper Privilege Management

结构: Simple

Abstraction: Class

状态: Draft

被利用可能性: Medium

基本描述

The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.

相关缺陷

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

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

适用平台

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

常见的影响

范围 影响 注释
Access Control Gain Privileges or Assume Identity

可能的缓解方案

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-49 Architecture and Design

策略: Separation of Privilege

Consider following the principle of separation of privilege. Require multiple conditions to be met before permitting access to a system resource.

示例代码

This code temporarily raises the program's privileges to allow creation of a new user folder.

bad Python

def makeNewUserDir(username):

if invalidUsername(username):


#avoid CWE-22 and CWE-78

print('Usernames cannot contain invalid characters')
return False

try:

raisePrivileges()
os.mkdir('/home/' + username)
lowerPrivileges()

except OSError:

print('Unable to create new user directory for user:' + username)
return False

return True

While the program only raises its privilege level to create the folder and immediately lowers it again, if the call to os.mkdir() throws an exception, the call to lowerPrivileges() will not occur. As a result, the program is indefinitely operating in a raised privilege state, possibly allowing further exploitation to occur.

Evidence of privilege change:

bad C

seteuid(0);
/ do some stuff /

seteuid(getuid());

bad Java

AccessController.doPrivileged(new PrivilegedAction() {

public Object run() {


// privileged code goes here, for example:

System.loadLibrary("awt");
return null;
// nothing to return

}

This code intends to allow only Administrators to print debug information about a system.

bad Java

public enum Roles {

ADMIN,USER,GUEST

}

public void printDebugInfo(User requestingUser){

if(isAuthenticated(requestingUser)){

switch(requestingUser.role){

case GUEST:

System.out.println("You are not authorized to perform this command");
break;

default:

System.out.println(currentDebugState());
break;

}

}
else{

System.out.println("You must be logged in to perform this command");

}

}

While the intention was to only allow Administrators to print the debug information, the code as written only excludes those the with the role of "GUEST". Someone with the role of "ADMIN" or "USER" will be allowed access, which goes against the original intent. An attacker may be able to use this debug information to craft an attack on the system.

This code allows someone with the role of "ADMIN" or "OPERATOR" to reset a user's password. The role of "OPERATOR" is intended to have less privileges than an "ADMIN", but still be able to help users with small issues such as forgotten passwords.

bad Java

public enum Roles {

ADMIN,OPERATOR,USER,GUEST

}

public void resetPassword(User requestingUser, User user, String password ){

if(isAuthenticated(requestingUser)){

switch(requestingUser.role){

case GUEST:

System.out.println("You are not authorized to perform this command");
break;

case USER:

System.out.println("You are not authorized to perform this command");
break;

default:

setPassword(user,password);
break;

}

}

else{

System.out.println("You must be logged in to perform this command");

}

}

This code does not check the role of the user whose password is being reset. It is possible for an Operator to gain Admin privileges by resetting the password of an Admin account and taking control of that account.

分析过的案例

标识 说明 链接
CVE-2001-1555 Terminal privileges are not reset when a user logs out. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-1555
CVE-2001-1514 Does not properly pass security context to child processes in certain cases, allows privilege escalation. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-1514
CVE-2001-0128 Does not properly compute roles. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2001-0128
CVE-1999-1193 untrusted user placed in unix "wheel" group https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-1193
CVE-2005-2741 Product allows users to grant themselves certain rights that can be used to escalate privileges. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2741
CVE-2005-2496 Product 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. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2496
CVE-2004-0274 Product mistakenly assigns a particular status to an entity, leading to increased privileges. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-0274
CVE-2007-4217 FTP client program on a certain OS runs with setuid privileges and has a buffer overflow. Most clients do not need extra privileges, so an overflow is not a vulnerability for those clients. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-4217
CVE-2007-5159 OS incorrectly installs a program with setuid privileges, allowing users to gain privileges. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-5159
CVE-2008-4638 Composite: application running with high privileges allows user to specify a restricted file to process, which generates a parsing error that leaks the contents of the file. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4638
CVE-2007-3931 Installation script installs some programs as setuid when they shouldn't be. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-3931
CVE-2002-1981 Roles have access to dangerous procedures (Accessible entities). https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-1981
CVE-2002-1671 Untrusted object/method gets access to clipboard (Accessible entities). https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-1671
CVE-2000-0315 Traceroute program allows unprivileged users to modify source address of packet (Accessible entities). https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-0315
CVE-2000-0506 User with capability can prevent setuid program from dropping privileges (Unsafe privileged actions). https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-0506

Notes

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER Privilege Management Error

相关攻击模式

  • CAPEC-122
  • CAPEC-233
  • CAPEC-58

引用

文章来源于互联网:scap中文网

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月16日16:17:00
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-269 特权管理不恰当http://cn-sec.com/archives/613126.html

发表评论

匿名网友 填写信息