Skip to content

Commit b2a2c09

Browse files
committed
disallow special name with ads
1 parent 4efac9d commit b2a2c09

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎CHANGES.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Version 3.1.9
55

66
Unreleased
77

8+
- ``safe_join`` on Windows does not allow special devices names with empty ADS
9+
markers on NTFS. :ghsa:`g6x2-hccm-hh4m`
810
- ``ProfilerMiddleware`` uses ``profiling.tracing`` on Python 3.15.
911
:issue:`3207`
1012
- ``uri_to_iri`` and ``iri_to_uri`` preserve empty username, password, and

‎src/werkzeug/security.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ def safe_join(directory: str, *untrusted: str) -> str | None:
173173
base directory.
174174
:return: A safe path, otherwise ``None``.
175175
176+
.. versionchanged:: 3.1.9
177+
Special device names with empty ADS stream markers are not allowed on
178+
Windows.
179+
176180
.. versionchanged:: 3.1.6
177181
Special device names in multi-segment paths are not allowed on Windows.
178182
@@ -206,7 +210,8 @@ def safe_join(directory: str, *untrusted: str) -> str | None:
206210
or (
207211
os.name == "nt"
208212
and any(
209-
p.partition(".")[0].strip().upper() in _windows_device_files
213+
p.partition(":")[0].partition(".")[0].strip().upper()
214+
in _windows_device_files
210215
for p in part.split("/")
211216
)
212217
)

0 commit comments

Comments
 (0)