CWE-243: Creation of chroot Jail Without Changing Working Directory
The product uses the chroot() system call to create a jail, but it does not change the working directory afterward.
Last updated
Overview
CWE-243 (Creation of chroot Jail Without Changing Working Directory) is a variant-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Background
The chroot() system call allows a process to change its perception of the root directory of the file system. After properly invoking chroot(), a process cannot access any files outside the directory tree defined by the new root directory. Such an environment is called a chroot jail and is commonly used to prevent the possibility that a process could be subverted and used to access unauthorized files. For instance, many FTP servers run in chroot jails to prevent an attacker who discovers a new vulnerability in the server from being able to download the password file or other sensitive files on the system.
Common consequences
What can happen when CWE-243 is exploited.
Read Files or Directories, Modify Files or Directories
Affects: Confidentiality, Integrity
If the working directory is not changed after the chroot() call, relative paths may still refer to file system resources outside of the jail. Attackers may be able to read or write to files outside of the jail.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages