bpo-43223: [SECURITY] Patched Open Redirection In SimpleHTTPServer Module#24848
bpo-43223: [SECURITY] Patched Open Redirection In SimpleHTTPServer Module#24848hamzaavvan wants to merge 1 commit into
Conversation
e2137b6 to
403490c
Compare
March 16, 2021 17:42
f61138a to
0fe6eed
Compare
March 16, 2021 18:09
vstinner
left a comment
There was a problem hiding this comment.
Can you please try to write an unit test?
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
|
Sorry I was busy with my other projects. |
Sorry, something went wrong.
0fe6eed to
3717f3f
Compare
May 6, 2021 12:34
|
Since I'm new to writing test cases, please help me in correcting the code if something went wrong. |
Sorry, something went wrong.
Fix an open redirection vulnerability in the HTTP server when a URL contains ``//``. Added test case for bpo-43223 patch
3717f3f to
42eb552
Compare
May 7, 2021 22:59
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
|
I've lost access to my account 😥 replying from email..
…On Fri, Apr 8, 2022, 6:26 PM Jakub Hadvig ***@***.***> wrote:
@hamzaavvan <https://github.com/hamzaavvan> ping :)
—
Reply to this email directly, view it on GitHub
<#24848 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNY3RNMO7QIH6RKTIMDD53VEAXYXANCNFSM4ZEGXF4Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sorry, something went wrong.
Due to no protection against multiple (/) at the beginning of a url an attacker could achieve an open redirection by crafting a malformed URI followed by an existing directory.
Payload:
http://127.0.0.1:8000//attacker.com/..%2f..%2f../anyexistingdirectoryThe main reason behind open redirection is that there's no (/) at the end of
anyexistingdirectorybecause the server is checking for the path supplied is a valid directory atsend_head()method from Lib/http/server.py. Right after that, it's checking for the path ending with a (/) or not. So, if there's no (/) at the end of the path then the server will issue a Location header to redirect the web client to that specific directory.While issuing the redirection, this part
//attacker.com/..%2f..%2f../anyexistingdirectorywill be sent to the Location header's value due to which any web client or browser will consider it as a new url because of multiple (/) at the beginning of the path.So to mitigate this issue I decided to use regex to replace all the occurrences of (/) from the beginning of the path.
This regex will replace multiple entries (if present) of (/) or (\) from the beginning of the path. So that the path would be:
And according to these test cases there was no redirection issued from the server after implementing the fix.
https://bugs.python.org/issue43223