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

[urllib] proxy_bypass_registry - extra error handling required for ProxyOverride, Windows under proxy environment #76646

Open
chansolkim mannequin opened this issue Dec 31, 2017 · 3 comments
Labels
3.11 only security fixes easy OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@chansolkim
Copy link
Mannequin

chansolkim mannequin commented Dec 31, 2017

BPO 32465
Nosy @iritkatriel

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2017-12-31.14:01:24.115>
labels = ['easy', 'type-bug', 'library', '3.11']
title = '[urllib] proxy_bypass_registry - extra error handling required for ProxyOverride, Windows under proxy environment'
updated_at = <Date 2021-06-18.09:32:03.073>
user = 'https://bugs.python.org/chansolkim'

bugs.python.org fields:

activity = <Date 2021-06-18.09:32:03.073>
actor = 'iritkatriel'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2017-12-31.14:01:24.115>
creator = 'chansol kim'
dependencies = []
files = []
hgrepos = []
issue_num = 32465
keywords = ['easy']
message_count = 2.0
messages = ['309284', '396036']
nosy_count = 2.0
nosy_names = ['chansol kim', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue32465'
versions = ['Python 3.11']

@chansolkim
Copy link
Mannequin Author

chansolkim mannequin commented Dec 31, 2017

[Problem]

  • String value from registry Proxy override is read and incorrectly decides the current connection requires not to use proxy.

[Setup]

  • Using urllib under proxy environment.
  • Proxy bypass settings are in place. ProxyOverride string value in registry ends with ;

[Detail]
https://github.com/python/cpython/blob/2.7/Lib/urllib.py
proxy_bypass_registry has an issue

  1. It gets registry value from HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyEnable string value.
  2. Splits the string with ;. And as the registry value ends with ; the split list contains a zero length string at the end.
  3. Use the split string to re.match. And as there is zero length string at the end it, and the result of re.match('', 'anystring', re.I) is always not None.
  4. Afterwards connection is attempted without using the proxy, hence connection cannot be made

From line 1617

        proxyOverride = proxyOverride.split(';')
        # now check if we match one of the registry values.
        for test in proxyOverride:
            if test == '<local>':
                if '.' not in rawHost:
                    return 1
            test = test.replace(".", r"\.")     # mask dots
            test = test.replace("*", r".*")     # change glob sequence
            test = test.replace("?", r".")      # change glob char
            for val in host:
                # print "%s <--> %s" %( test, val )
                if re.match(test, val, re.I):
                    return 1

@chansolkim chansolkim mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 31, 2017
@iritkatriel
Copy link
Member

There are currently no unit tests for proxy_bypass_registry, proxy_bypass, and nothing much for proxy_open. Those should be added as part of this work.

@iritkatriel iritkatriel added easy 3.11 only security fixes labels Jun 18, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@mblahay
Copy link
Contributor

mblahay commented Apr 26, 2023

Should this be tagged with OS-windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes easy OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants