Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when verify is invalid UNC path #5850

Closed
tl-hbk opened this issue Jun 29, 2021 · 1 comment · Fixed by #5851
Closed

Infinite loop when verify is invalid UNC path #5850

tl-hbk opened this issue Jun 29, 2021 · 1 comment · Fixed by #5851

Comments

@tl-hbk
Copy link
Contributor

tl-hbk commented Jun 29, 2021

When an invalid UNC path is passed to requests.utils.extract_zipped_paths it results in an infinite loop

Expected Result

For extract_zipped_paths to return the path and an Exception to be thrown when the cert path is checked prior to verification being attempted.

Actual Result

Code gets stuck looping here

requests/requests/utils.py

Lines 245 to 248 in 5855dd7

archive, member = os.path.split(path)
while archive and not os.path.exists(archive):
archive, prefix = os.path.split(archive)
member = '/'.join([prefix, member])

Reproduction Steps

import requests.utils
requests.utils.extract_zipped_paths(r"\\localhost\a\b\c")  # Assumes this path is invalid on testing machine

System Information

$ python -m requests.help
{
  "chardet": {
    "version": "4.0.0"
  },
  "cryptography": {
    "version": "3.4.7"
  },
  "idna": {
    "version": "2.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.10"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "101010bf",
    "version": "20.0.1"
  },
  "requests": {
    "version": "2.25.1"
  },
  "system_ssl": {
    "version": "101010bf"
  },
  "urllib3": {
    "version": "1.26.4"
  },
  "using_pyopenssl": true
}

This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).

@tl-hbk
Copy link
Contributor Author

tl-hbk commented Jun 29, 2021

This code path is only hit when using a patched certifi package that has certifi.where() return a UNC path

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant