CAPEC-27
Leveraging Race Conditions via Symbolic Links
This attack leverages the use of symbolic links (Symlinks) in order to write to sensitive files. An attacker can create a Symlink link to a target file not otherwise accessible to them. When the privileged program tries to create a temporary file with the same name as the Symlink link, it will actually write to the target file pointed to by the attackers' Symlink link. If the attacker can insert malicious content in the temporary file they will be writing to the sensitive file by using the Symlink. The race occurs because the system checks if the temporary file exists, then creates the file. The attacker would typically create the Symlink during the interval between the check and the creation of the temporary file.
On this page
Ask an AI about this attack pattern
Show the prompt
Explain the attack pattern CAPEC-27: Leveraging Race Conditions via Symbolic Links: how it unfolds, what it needs and how to prevent and detect it in my systems. Use https://capec.mitre.org/data/definitions/27.html and https://cve.bz/cve/capec/27?via=ask-ai-copy, which lists recent CVEs with the weaknesses it exploits. Cite the sources.Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this attack pattern's id and public links.
How the attack unfolds
Explore
The attacker looks for a way in.
[Verify that target host's platform supports symbolic links.] This attack pattern is only applicable on platforms that support symbolic links.
2 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.
[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.
4 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
They probe what they found.
[Verify ability to write to filesystem] The attacker verifies ability to write to the target host's file system.
3 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
They carry out the attack.
[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.
2 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.
Prerequisites
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.
Skills required
- Medium skill
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).
Consequences
| Impact | Affects | Note |
|---|---|---|
| Modify Data | Integrity | |
| Gain Privileges | Confidentiality, Access Control, Authorization | |
| Resource Consumption | Availability | Denial of Service |
Mitigations
Use safe libraries when creating temporary files. For instance the standard library function mkstemp can be used to safely create temporary files. For shell scripts, the system utility mktemp does the same thing.
Access to the directories should be restricted as to prevent attackers from manipulating the files. Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file.
Follow the principle of least privilege when assigning access rights to files.
Ensure good compartmentalization in the system to provide protected areas that can be trusted.
Weaknesses it exploits
- CWE-61 UNIX Symbolic Link (Symlink) Following
- CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
- CWE-662 Improper Synchronization
- CWE-667 Improper Locking
- CWE-689 Permission Race Condition During Resource Copy
Recent CVEs with these weaknesses
- 7.3CVE-2026-92864
Insecure Temporary File Vulnerability in Hitachi Dynamic Link Manager for AIX (for markets outside Japan) and Hitachi Dynamic Link Manager EX for AIX (for the Japanese market). This issue affects Hitachi Dynamic Link Manager for AIX: from…
- 8.2CVE-2026-91763
UNIX Symbolic Link (Symlink) Following Vulnerability in Hitachi Dynamic Link Manager for Linux. This issue affects Hitachi Dynamic Link Manager for Linux: from 8.6.2.-00 before 9.0.5-00.
- 7.9CVE-2026-91762
UNIX Symbolic Link (Symlink) Following Vulnerability in Hitachi Dynamic Link Manager for Linux. This issue affects Hitachi Dynamic Link Manager for Linux: from 8.5.3.-00 before 9.0.5-00.
- 8.2CVE-2026-91761
UNIX Symbolic Link (Symlink) Following Vulnerability in Hitachi Dynamic Link Manager for Linux. This issue affects Hitachi Dynamic Link Manager for Linux: from 8.6.2.-00 before 9.0.5-00.
- 5.4CVE-2026-114594
A time-of-check to time-of-use (TOCTOU) race condition in the Sandisk Dashboard installer allows a local, authenticated standard user to replace an installer-staged binary in a user-writable temporary directory between validation and execu…
- 4.8CVE-2026-124622
A vulnerability was identified in olivier-ls PHP-FTS up to 1.1.3. This impacts the function TrigramIndex::open of the file Storage.php. Such manipulation leads to time-of-check time-of-use. The attack needs to be performed locally. Upgradi…
- 6.0CVE-2026-92606
Time-of-check time-of-use (TOCTOU) race condition vulnerability in TÜBİTAK BİLGEM Software Technologies Research Institute Pardus MyComputer allows Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions. This issue affects Pard…
- 4.8CVE-2026-124584
A vulnerability has been found in wummel patool 4.1.0. This vulnerability affects the function extract_gzip of the file patoolib/fileutil.py of the component Gzip Extraction Handler. The manipulation leads to symlink following. Local acces…
The newest records naming one of them. Each weakness's page lists them all.
Related attack patterns
- Part of
- CAPEC-29 Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
Examples
In this naive example, the Unix program foo is setuid. Its function is to retrieve information for the accoun…
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 tempora…
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 …
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, leak…
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
MITRE's words, unchanged: CAPEC-27 at MITRE. CAPEC is Copyright © 2007–2026, The MITRE Corporation, used under the CAPEC terms of use: “The MITRE Corporation (MITRE) hereby grants you a non-exclusive, royalty-free license to use Common Attack Pattern Enumeration and Classification (CAPEC™) for research, development, and commercial purposes. Any copy you make for such purposes is authorized provided that you reproduce MITRE’s copyright designation and this license in any such copy.” CAPEC and the CAPEC logo are trademarks of The MITRE Corporation. Credits. All attack patterns.