CWE

Common Weakness Enumeration

社区开发的软件和硬件弱点类型清单

2021 CWE最重要的硬件弱点
CWE前25个最危险的弱点
Home>CWEList> cwe-单个字典定义(4.10)
ID

CWE-426:不受信任的搜索路径

弱点ID:426
Abstraction:Base
结构:简单的
View customized information:
+描述
产品使用外部供应搜索路径来搜索关键资源,该搜索路径可以指向不在产品直接控制下的资源。
+Extended Description

This might allow attackers to execute their own programs, access unauthorized data files, or modify configuration in unexpected ways. If the product uses a search path to locate critical resources such as programs, then an attacker could modify that search path to point to a malicious program, which the targeted product would then execute. The problem extends to any type of critical resource that the product trusts.

不受信任的搜索路径的一些最常见的变体是:

  • 在基于UNIX和Linux的各种系统中,可以咨询路径环境变量以找到可执行程序,并且可以使用LD_Preload来定位单独的库。
  • 在基于微软的各种系统中,如果未在搜索顺序以前出现的其他路径中找到DLL,请咨询路径环境变量以找到DLL。
+替代条款
不受信任的路径
+Relationships
Section Help该表显示了与该弱点相关的弱点和高级类别。这些关系定义为childof,parentof,ementof,并深入了解可能存在于较高和较低抽象水平的类似项目。此外,定义了诸如Peerof和Canalsobe之类的关系,以显示用户可能想要探索的类似弱点。
+与观点“研究概念”相关(CWE-1000)
自然 类型 ID 姓名
Childof Class班级 - 以非常抽象的方式描述的弱点,通常与任何特定的语言或技术无关。比支柱弱点更具体,但比基本弱点更一般。班级弱点通常用以下维度的1或2来描述问题:行为,属性和资源。 673 External Influence of Sphere Definition
Childof Class班级 - 以非常抽象的方式描述的弱点,通常与任何特定的语言或技术无关。比支柱弱点更具体,但比基本弱点更一般。班级弱点通常用以下维度的1或2来描述问题:行为,属性和资源。 642 External Control of Critical State Data
PeerOf Base基础 - 仍然主要独立于资源或技术的弱点,但有足够的细节来提供特定的检测和预防方法。基本水平的弱点通常用以下维度的2或3来描述问题:行为,财产,技术,语言和资源。 427 Uncontrolled Search Path Element
PeerOf Base基础 - 仍然主要独立于资源或技术的弱点,但有足够的细节来提供特定的检测和预防方法。基本水平的弱点通常用以下维度的2或3来描述问题:行为,财产,技术,语言和资源。 428 未引用的搜索路径或元素
Section Help该表显示了与该弱点相关的弱点和高级类别。这些关系定义为childof,parentof,ementof,并深入了解可能存在于较高和较低抽象水平的类似项目。此外,定义了诸如Peerof和Canalsobe之类的关系,以显示用户可能想要探索的类似弱点。
+与“软件开发”视图相关(CWE-699)
自然 类型 ID 姓名
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 1219 文件处理问题
Section Help该表显示了与该弱点相关的弱点和高级类别。这些关系定义为childof,parentof,ementof,并深入了解可能存在于较高和较低抽象水平的类似项目。此外,定义了诸如Peerof和Canalsobe之类的关系,以显示用户可能想要探索的类似弱点。
+与“简化已发表漏洞的简化映射”(CWE-1003)相关的视图相关(CWE-1003)
自然 类型 ID 姓名
Childof Class班级 - 以非常抽象的方式描述的弱点,通常与任何特定的语言或技术无关。比支柱弱点更具体,但比基本弱点更一般。班级弱点通常用以下维度的1或2来描述问题:行为,属性和资源。 668 资源暴露于错误的领域
Section Help该表显示了与该弱点相关的弱点和高级类别。这些关系定义为childof,parentof,ementof,并深入了解可能存在于较高和较低抽象水平的类似项目。此外,定义了诸如Peerof和Canalsobe之类的关系,以显示用户可能想要探索的类似弱点。
+与“建筑概念”(CWE-1008)有关
自然 类型 ID 姓名
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 1011 授权演员
+介绍模式
Section Help引言的不同模式提供了有关如何以及何时引入这种弱点的信息。该阶段识别可能发生介绍的生命周期中的一个点,而音符提供了与给定阶段中引言有关的典型情况。
阶段 笔记
Architecture and Design
执行
+适用的平台
Section Help该清单显示了可能出现的弱点的可能区域。这些可能适用于特定的命名语言,操作系统,体系结构,范式,技术或一类此类平台。该平台与给定弱点出现在该实例的频率一起列出。

语言

Class: Not Language-Specific(Undetermined Prevalence)

操作系统

班级:不是特定于操作系统的(Undetermined Prevalence)

+常见后果
Section Help该表指定与弱点相关的不同个人后果。该范围确定了违反的应用程序安全区域,而影响描述了如果对手成功利用这一弱点,就会产生负面的技术影响。其可能性提供了有关预期相对于列表中其他后果的特定后果的可能性的信息。例如,可能会利用弱点来实现一定的影响,但很可能会利用它来实现不同的影响。
Scope 影响 可能性
正直
保密
可用性
Access Control

技术影响:获得特权或假定身份;执行未经授权的代码或命令

具有脆弱程序特权的任意代码执行的潜力。
可用性

技术影响:DOS:崩溃,退出或重新启动

可以将程序重定向到错误的文件,当目标文件太大或没有预期格式时,可能会触发崩溃或悬挂。
保密

技术影响:读取文件或目录

该程序可以将未经授权文件的输出发送给攻击者。
+可能性Of Exploit
高的
+示例的例子

示例1

该程序旨在执行命令列出限制目录的内容,然后执行其他操作的命令。假设它具有setuid特权运行,以绕过操作系统的权限检查。

(bad code)
示例语言:C
#define dir“/限制/目录”

char cmd [500];
Sprintf(CMD,“ LS -L%480S”,DIR);
/*将特权提高到访问DIR所需的特权。*/

Raiseprivileges(...);
system(cmd);
Dropprivileges(...);
...

This code may look harmless at first, since both the directory and the command are set to fixed values that the attacker can't control. The attacker can only see the contents for DIR, which is the intended program behavior. Finally, the programmer is also careful to limit the code that executes with raised privileges.

但是,由于该程序不会修改路径环境变量,因此以下攻击将起作用:

(攻击代码)
  • 用户设置了在攻击者控件下引用目录的路径,例如“/my/dir/”。
  • 攻击者创建了一个名为“ LS”的恶意程序,并将该程序放入 /my /dir中
  • 用户执行程序。
  • 执行System()时,Shell会咨询找到LS程序的路径
  • 该程序找到了攻击者的恶意程序“/my/dir/ls”。它找不到“/bin/ls”,因为路径不包含“/bin/”。
  • The program executes the attacker's malicious program with the raised privileges.

示例2

该代码打印所有属于当前用户的运行过程。

(bad code)
示例语言:php

//assume getCurrentUser() returns a username that is guaranteed to be alphanumeric (avoidingCWE-78
$ username = getCurrentuser();
$ command ='PS Aux |格雷普'。$ username;
系统($命令);

如果由未经授权的Web用户调用,它将提供有关基础系统的潜在敏感信息的网页,例如命令行参数(CWE-497)。This program is also potentially vulnerable to a PATH based attack (CWE-426),作为攻击者可能能够创建PS或GREP命令的恶意版本。尽管该程序没有明确提高运行系统命令的特权,但默认情况下,PHP解释器可能比用户更高的特权运行。

示例3

The following code is from a web application that allows users access to an interface through which they can update their password on the system. In this environment, user passwords can be managed using the Network Information System (NIS), which is commonly used on UNIX systems. When performing NIS updates, part of the process for updating passwords is to run a make command in the /var/yp directory. Performing NIS updates requires extra privileges.

(bad code)
示例语言:爪哇
...
system.runtime.getRuntime()。exec(“ make”);
...

这里的问题在于,该程序在执行call to Runtime.exec()之前没有指定制造和清洁其环境的绝对路径。如果攻击者可以修改$路径变量,以指向称为Make的恶意二进制,并导致该程序在其环境中执行,则将加载恶意二进制,而不是预期的。由于应用程序的性质,它具有执行系统操作所需的特权,这意味着攻击者的制造现在将使用这些特权运行,可能使攻击者完全控制系统。

+观察到的例子
参考 描述
应用程序依赖其路径环境变量来查找和执行程序。
数据库应用程序依赖其路径环境变量来查找和执行程序。
链:通过加载恶意国际化消息,不受信任的搜索路径启用了结果格式字符串。
Untrusted search path using malicious .EXE in Windows environment.
SetUID程序允许使用查找和加载恶意库的路径进行妥协。
服务器允许客户端指定搜索路径,可以对其进行修改以指向客户端已上传的程序。
+潜在的缓解

阶段:建筑和设计;执行

策略:减少攻击表面

将搜索路径硬编码到一组已知安全值(例如系统目录),或者仅允许管理员在配置文件中指定它们。不要允许外部方修改这些设置。小心避免相关弱点,例如CWE-426CWE-428

阶段:实施

When invoking other programs, specify those programs using fully-qualified pathnames. While this is an effective approach, code that uses fully-qualified pathnames might not be portable to other systems that do not use the same pathnames. The portability can be improved by locating the full-qualified paths in a centralized, easily-modifiable location within the source code, and having the code refer to these paths.

阶段:实施

Remove or restrict all environment settings before invoking other programs. This includes the PATH environment variable, LD_LIBRARY_PATH, and other settings that identify the location of code libraries, and any application-specific search paths.

阶段:实施

使用前检查您的搜索路径,然后删除所有可能不安全的元素,例如当前的工作目录或临时文件目录。

阶段:实施

使用其他需要明确路径的功能。利用需要明确路径的任何其他随时可用的功能是避免此问题的安全方法。例如,C中的System()不需要完整的路径,因为外壳可以照顾它,而Execl()和Execv()需要完整的路径。
+Detection Methods

黑盒子

Use monitoring tools that examine the software's process as it interacts with the operating system and the network. This technique is useful in cases when source code is unavailable, if the software was not developed by you, or if you want to verify that the build phase did not introduce any new weaknesses. Examples include debuggers that directly attach to the running process; system-call tracing utilities such as truss (Solaris) and strace (Linux); system activity monitors such as FileMon, RegMon, Process Monitor, and other Sysinternals utilities (Windows); and sniffers and protocol analyzers that monitor network traffic.

将监视器附加到该过程中,并查找库时的库功能和系统调用,这些功能建议使用搜索路径。一种模式是,当程序执行同一文件的多个访问权限时,但在不同的目录中进行重复故障,直到找到正确的文件名。可以检查诸如getEnv()或其等效的库呼叫,以查看是否访问了任何与路径相关的变量。

自动静态分析

使用针对此类弱点的自动静态分析工具。许多现代技术使用数据流分析来最大程度地减少误报数量。这不是一个完美的解决方案,因为100%的准确性和覆盖范围不可行。

手动分析

使用需要手动分析的工具和技术,例如渗透测试,威胁建模和交互式工具,使测试人员可以记录和修改活动会话。这些可能比严格自动化的技术更有效。与设计和业务规则相关的弱点尤其如此。
+功能区域
  • 程序调用
  • 代码库
+影响资源
  • 系统过程
+会员资格
Section HelpThis MemberOf Relationships table shows additional CWE Categories and Views that reference this weakness as a member. This information is often useful in understanding where a weakness fits within the context of external information sources.
自然 类型 ID 姓名
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 744 证书C安全编码标准(2008)第11章 - 环境(ENV)
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 752 2009 Top 25 - Risky Resource Management
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 808 2010 Top 25 - Weaknesses On the Cusp
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 878 CERT C ++安全编码第10节 - 环境(ENV)
MemberOf View查看 - CWE条目的子集,提供了一种检查CWE内容的方法。两个主视图结构是切片(平面列表)和图(包含条目之间的关系)。 1200 2019年CWE前25个最危险的软件错误中的弱点
MemberOf 类别类别 - 包含共享共同特征的其他条目的CWE条目。 1354 OWASP Top Ten 2021 Category A08:2021 - Software and Data Integrity Failures
+分类映射
Mapped Taxonomy Name Node ID 合身 Mapped Node Name
plover 不信任的搜索路径
扣子 相对路径库搜索
证书C安全编码 ENV03-C Sanitize the environment when invoking external programs
+参考
[Ref-18] Secure Software,Inc.。“ The CLASP应用程序安全过程”。2005年。<https://cwe.mitre.org/documents/sources/TheCLASPApplicationSecurityProcess.pdf>。
[REF-62] Mark Dowd, John McDonald and Justin Schuh. "The Art of Software Security Assessment". Chapter 10, Process Attributes, page 603. 1st Edition. Addison Wesley. 2006.
[REF-176] Michael Howard and David LeBlanc. "Writing Secure Code". Chapter 8, "Canonical Representation Issues." Page 229. 1st Edition. Microsoft Press. 2001-11-13.
[Ref-207] John Viega和Gary McGraw。“构建安全软件:如何以正确的方式避免安全问题”。第12章,“信任管理和输入验证”。第317-320页。第一版。Addison-Wesley。2002。
[Ref-7] Michael Howard和David LeBlanc。“编写安全代码”。第11章,“不信任路径 - 使用完整的路径名”第385页。第二版。Microsoft Press。2002-12-04。<https://www.microsoftpressstore.com/store/writing-secure-code-9780735617223>。
+内容历史记录
+提交
提交日期 Submitter 组织
2006-07-19 plover
+修改
修改日期 修饰符 组织
2008-07-01 埃里克·达奇(Eric Dalci) 雪茄
更新的time_of_introduction
2008-09-08 CWEContent Team MITER
更新的common_cconsquences, Relationships, Taxonomy_Mappings
2008-11-24 CWEContent Team MITER
更新的关系,分类_mappings
2009-01-12 CWEContent Team MITER
更新的适用_platforms,common_consequences,expdiveative_examples,描述,obsoved_examples,势_Mitigations,关系,time_of_introduction
2009-03-10 CWEContent Team MITER
更新了示范_examples,势_mitigations
2009-12-28 CWEContent Team MITER
更新的引用
2010-02-16 CWEContent Team MITER
更新的引用,关系
2010-04-05 CWEContent Team MITER
更新了适用的_platforms
2010-06-21 CWEContent Team MITER
updated Detection_Factors, Potential_Mitigations
2010-09-27 CWEContent Team MITER
更新的描述,关系
2011-03-29 CWEContent Team MITER
更新了示范_examples
2011-06-01 CWEContent Team MITER
更新的common_cconsquences
2011-09-13 CWEContent Team MITER
更新的关系,分类_mappings
2012-05-11 CWEContent Team MITER
更新的示范_examples,参考
2014-02-18 CWEContent Team MITER
更新了示范示例,distection_factors,势_MITIGITATION
2015-12-07 CWEContent Team MITER
更新的关系
2017-11-08 CWEContent Team MITER
更新的示范_examples,modes_of_introduction,参考,关系,分类_mappings
2018-03-27 CWEContent Team MITER
更新了示范示例,参考,关系,类型
2019-01-03 CWEContent Team MITER
更新相关的_attack_patterns
2019-06-20 CWEContent Team MITER
更新相关的_attack_patterns,关系
2019-09-19 CWEContent Team MITER
更新的关系
2020-02-24 CWEContent Team MITER
更新的引用,关系
2021-03-15 CWEContent Team MITER
更新了示范_examples
2021-10-28 CWEContent Team MITER
更新的关系
2022-04-28 CWEContent Team MITER
更新的Research_gaps
2023-01-31 CWEContent Team MITER
updated Description
提供更多信息 - 请选择其他过滤器。
页面最后更新:2023年1月31日