You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zoneinfo.ZoneInfo accepts keys with a drive letter in a later component on Windows #160420
On Windows, zoneinfo.ZoneInfo accepts a key in which a component after a / starts with a drive letter, such as America/C:\Windows\win.ini. The key validation in zoneinfo._tzpath._validate_tzfile_path() looks at the key as one string, where a drive is only recognised at the very start, but zoneinfo._common.load_tzdata() splits the key on / and joins the last component to the tzdata package directory by itself, and a component with a drive and root replaces that directory. With the tzdata package installed, the named file is opened and handed to the TZif parser instead of the key being rejected with ValueError. The loader has worked this way since GH-30190 (3.11).
A program that passes a time zone name from a request or a document to ZoneInfo lets whoever supplies the name find out whether a file at a drive-letter path exists and can be opened, by telling ZoneInfoNotFoundError from ValueError: Invalid TZif file: magic not found or PermissionError; file contents are not returned unless the file is a valid TZif file.
I have not run this on Windows. The script below runs the real validator against ntpath on Linux and models the join done by load_tzdata() with PureWindowsPath; it opens no file.
importntpath, typesfrompathlibimportPureWindowsPathfromzoneinfoimport_tzpath# Windows path rules, simulated: no file is opened._tzpath.os=types.SimpleNamespace(path=ntpath)
key=r"America/C:\Windows\win.ini"_tzpath._validate_tzfile_path(key, _base="_\\") # no ValueError# What zoneinfo._common.load_tzdata() then does with the key:*package, resource=key.split("/")
tzdata=PureWindowsPath(r"C:\Python\Lib\site-packages\tzdata\zoneinfo")
print(tzdata.joinpath(*package).joinpath(resource))
This prints C:\Windows\win.ini. Expected: the validator raises ValueError, as it does for C:\Windows\win.ini and ../x.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Other (not run on Windows; Windows path handling simulated on Linux as described above)
Activity
StanFromIreland commentedon Oct 23, 2026
I don't think this is a security vulnerability, as we've decided previously for
zoneinfo, passing untrusted input is not part of its threat model.gh-160420: Reject drive letters in ZoneInfo key components on Windows (…