Skip to content

In Windows, os.path.ismount() returns True for nonsense UNC shares #139916

@cowgoesmoo69

Description

@cowgoesmoo69

Bug report

Bug description:

Examples below:

  • \\192.168.10.2\share1 is a valid UNC.
  • \\192.168.10.34534543.2\share1 is an invalid UNC as it has five IPv4 octets and an octet is out of range.
  • \\"!£$£"$%\share1 is an invalid UNC as it contains illegal characters.
C:\Users\earpt\source\repos\cowgoesmoo69\cpython>python.bat
Running Debug|x64 interpreter...
Python 3.15.0a0 (heads/main:1c598e0436, Oct 10 2025, 18:08:52) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.ismount("\\\\192.168.10.2\\share1")
True
>>> os.path.ismount("\\\\192.168.10.34534543.2\\share1")
True
>>> os.path.ismount("\\\\\"!£$£\"$%\\share1")
True
>>>

It appears there is no validation in ntpath.ismount() of a path that appears to be a UNC.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsstdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions