python / python/cpython

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

Open
#139,916 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

OS-windows stdlib topic-pathlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ntpath.ismount() and reproduce the UNC examples on Windows using the commands in the issue. Done means valid UNC shares retain the expected result while malformed addresses and illegal-character shares no longer return True.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.