Dark Mode
Capec-27 Detail
Leveraging Race Conditions via Symbolic Links
Detailed Software Likelihood: Medium Typical Severity: High
Parents: 29
Threats: T79 T287 T337 T391 T406
Not present
| External ID | Source | Link | Description |
|---|---|---|---|
| CAPEC-27 | capec | https://capec.mitre.org/data/definitions/27.html | |
| CWE-367 | cwe | http://cwe.mitre.org/data/definitions/367.html | |
| CWE-61 | cwe | http://cwe.mitre.org/data/definitions/61.html | |
| CWE-662 | cwe | http://cwe.mitre.org/data/definitions/662.html | |
| CWE-689 | cwe | http://cwe.mitre.org/data/definitions/689.html | |
| CWE-667 | cwe | http://cwe.mitre.org/data/definitions/667.html | |
| REF-115 | reference_from_CAPEC | http://en.wikipedia.org/wiki/Symlink_race | Wikipedia, The Wikimedia Foundation, Inc |
| REF-116 | reference_from_CAPEC | http://www.opengroup.org/onlinepubs/009695399/functions/mkstemp.html | mkstemp (IEEE Std 1003.1, 2004 Edition), The Open Group Base Specifications Issue 6 |
Explore
-
Verify that target host's platform supports symbolic links.: This attack pattern is only applicable on platforms that support symbolic links.
-
Examine application's file I/O behavior: Analyze the application's file I/O behavior to determine where it stores files, as well as the operations it performs to read/write files.
| Techniques |
|---|
| Research target platform to determine whether it supports symbolic links. |
| Create a symbolic link and ensure that it works as expected on the given platform. |
| Techniques |
|---|
| Use kernel tracing utility such as ktrace to monitor application behavior. |
| Use debugging utility such as File Monitor to monitor the application's filesystem I/O calls |
| Watch temporary directories to see when temporary files are created, modified and deleted. |
| Analyze source code for open-source systems like Linux, Apache, etc. |
Experiment
-
Verify ability to write to filesystem: The attacker verifies ability to write to the target host's file system.
| Techniques |
|---|
| Create a file that does not exist in the target directory (e.g. "touch temp.txt" in UNIX-like systems) |
| On platforms that differentiate between file creation and file modification, if the target file that the application writes to already exists, attempt to modify it. |
| Verify permissions on target directory |
Exploit
-
Replace file with a symlink to a sensitive system file.: Between the time that the application checks to see if a file exists (or if the user has access to it) and the time the application actually opens the file, the attacker replaces the file with a symlink to a sensitive system file.
| Techniques |
|---|
| Create an infinite loop containing commands such as "rm -f tempfile.dat; ln -s /etc/shadow tempfile.dat". Wait for an instance where the following steps occur in the given order: (1) Application ensures that tempfile.dat exists and that the user has access to it, (2) "rm -f tempfile.dat; ln -s /etc/shadow tempfile.dat", and (3) Application opens tempfile.dat for writing, and inadvertently opens /etc/shadow for writing instead. |
| Use other techniques with debugging tools to replace the file between the time the application checks the file and the time the application opens it. |
- The attacker is able to create Symlink links on the target host.
- Tainted data from the attacker is used and copied to temporary files.
- The target host does insecure temporary file creation.
Not present
| Medium |
|---|
| This attack is sophisticated because the attacker has to overcome a few challenges such as creating symlinks on the target host during a precise timing, inserting malicious data in the temporary file and have knowledge about the temporary files created (file name and function which creates them). |
| Integrity | Availability | Authorization | Access Control | Confidentiality |
|---|---|---|---|---|
| Modify Data | Resource Consumption (Denial of Service) | Gain Privileges | Gain Privileges | Gain Privileges |
- In this naive example, the Unix program foo is setuid. Its function is to retrieve information for the accounts specified by the user. For "efficiency," it sorts the requested accounts into a temporary file (/tmp/foo naturally) before making the queries. The directory /tmp is world-writable. The malicious user creates a symbolic link to the file /.rhosts named /tmp/foo. Then, they invokes foo with "user" as the requested account. The program creates the (temporary) file /tmp/foo (really creating /.rhosts) and puts the requested account (e.g. "user password")) in it. It removes the temporary file (merely removing the symbolic link). Now the /.rhosts contains + +, which is the incantation necessary to allow anyone to use rlogin to log into the computer as the superuser. [REF-115]
- GNU "ed" utility (before 0.3) allows local users to overwrite arbitrary files via a symlink attack on temporary files, possibly in the open_sbuf function. See also: CVE-2006-6939
- OpenmosixCollector and OpenMosixView in OpenMosixView 1.5 allow local users to overwrite or delete arbitrary files via a symlink attack on (1) temporary files in the openmosixcollector directory or (2) nodes.tmp. See also: CVE-2005-0894
- Setuid product allows file reading by replacing a file being edited with a symlink to the targeted file, leaking the result in error messages when parsing fails. See also: CVE-2000-0972