Werkzeug Safe Join Function Vulnerability Allowing Windows Device Names

Vulnerability

A vulnerability exists in Werkzeug versions prior to 3.1.6 within the safe_join function, which improperly allows Windows special device names as filenames if preceded by other path segments. This issue arises because safe_join can handle multi-segment paths, such as 'example/NUL'. The vulnerability is exploited when the send_from_directory function, which relies on safe_join to serve files from user-specified paths, is used on a Windows system. If the requested path ends with a device name, the file will be opened, but the read operation will hang indefinitely.

Impact

Exploitation of this vulnerability leads to a denial-of-service condition, where the application hangs indefinitely while attempting to read a file that was opened successfully.

Reproduction

To reproduce this vulnerability, use Werkzeug versions prior to 3.1.6 and create a path that includes a Windows special device name, such as 'NUL', preceded by another path segment. When this path is requested through the send_from_directory function, the application will hang while trying to read the file, demonstrating the denial-of-service condition.

Remediation

Users can upgrade to Werkzeug version 3.1.6 or later, where this vulnerability has been fixed.

Added: Feb 21, 2026, 7:13 AM
Updated: Feb 21, 2026, 7:13 AM

Vulnerability Rating

Custom Algorithm
spread
8.1
impact
2.5
exploitability
6.9
remediation
7.7
relevance
3.1
threat
4.8
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.