Description
The product checks the status of a file or directory before accessing it, which produces a race condition in which the file can be replaced with a link before the access is performed, causing the product to access the wrong file.
While developers might expect that there is a very narrow time window between the time of check and time of use, there is still a race condition. An attacker could cause the product to slow down (e.g. with memory consumption), causing the time window to become larger. Alternately, in some situations, the attacker could win the race by performing a large number of attacks.
Potential Impact
Confidentiality, Integrity
Read Files or Directories, Modify Files or Directories
Demonstrative Examples
function readFile($filename){
$user = getCurrentUser();
//resolve file if its a symbolic link
if(is_link($filename)){$filename = readlink($filename);}
if(fileowner($filename) == $user){echo file_get_contents($realFile);return;}else{echo 'Access denied';return false;}
}Detection Methods
- Automated Static Analysis — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Related Weaknesses
Taxonomy Mappings
- PLOVER: — Race condition enabling link following
- CERT C Secure Coding: POS35-C — Avoid race conditions while checking for the existence of a symbolic link
- Software Fault Patterns: SFP20 — Race Condition Window
Frequently Asked Questions
What is CWE-363?
CWE-363 (Race Condition Enabling Link Following) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product checks the status of a file or directory before accessing it, which produces a race condition in which the file can be replaced with a link before the access is performed, causing the prod...
How can CWE-363 be exploited?
Attackers can exploit CWE-363 (Race Condition Enabling Link Following) to read files or directories, modify files or directories. This weakness is typically introduced during the Architecture and Design, Implementation phase of software development.
How do I prevent CWE-363?
Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.
What is the severity of CWE-363?
CWE-363 is classified as a Base-level weakness (Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.