CWE-243 未改变工作目录时创建chroot Jail

admin 2022年1月5日21:04:24评论112 views字数 1724阅读5分44秒阅读模式

CWE-243 未改变工作目录时创建chroot Jail

Creation of chroot Jail Without Changing Working Directory

结构: Simple

Abstraction: Variant

状态: Draft

被利用可能性: High

基本描述

The program uses the chroot() system call to create a jail, but does not change the working directory afterward. This does not prevent access to files outside of the jail.

扩展描述

Improper use of chroot() may allow attackers to escape from the chroot jail. The chroot() function call does not change the process's current working directory, so relative paths may still refer to file system resources outside of the chroot jail after chroot() has been called.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 573 cwe_View_ID: 1000

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

适用平台

Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}]

Operating_System: {'cwe_Class': 'Unix', 'cwe_Prevalence': 'Undetermined'}

常见的影响

范围 影响 注释
Confidentiality Read Files or Directories

示例代码

Consider the following source code from a (hypothetical) FTP server:

bad C

chroot("/var/ftproot");
...
fgets(filename, sizeof(filename), network);
localfile = fopen(filename, "r");
while ((len = fread(buf, 1, sizeof(buf), localfile)) != EOF) {

fwrite(buf, 1, sizeof(buf), network);

}
fclose(localfile);

This code is responsible for reading a filename from the network, opening the corresponding file on the local machine, and sending the contents over the network. This code could be used to implement the FTP GET command. The FTP server calls chroot() in its initialization routines in an attempt to prevent access to files outside of /var/ftproot. But because the server does not change the current working directory by calling chdir("/"), an attacker could request the file "../../../../../etc/passwd" and obtain a copy of the system password file.

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
7 Pernicious Kingdoms Directory Restriction
Software Fault Patterns SFP17 Failed chroot jail

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

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月5日21:04:24
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-243 未改变工作目录时创建chroot Jailhttp://cn-sec.com/archives/612815.html

发表评论

匿名网友 填写信息