Title: bpo-43223: [SECURITY] Patched Open Redirection In SimpleHTTPServer Module by hamzaavvan · Pull Request #24848 · python/cpython · GitHub
Open Graph Title: bpo-43223: [SECURITY] Patched Open Redirection In SimpleHTTPServer Module by hamzaavvan · Pull Request #24848 · python/cpython
X Title: bpo-43223: [SECURITY] Patched Open Redirection In SimpleHTTPServer Module by hamzaavvan · Pull Request #24848 · python/cpython
Description: 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/../../../anyexistingdirectory The main reason behind open redirection is that there's no (/) at the end of anyexistingdirectory because the server is checking for the path supplied is a valid directory at send_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/../../../anyexistingdirectory will 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. self.path = re.sub(r'(^(/|\\)+)', '/', self.path) This regex will replace multiple entries (if present) of (/) or (\) from the beginning of the path. So that the path would be: //attacker.com/../../../anyexistingdirectory -> /attacker.com/../../../anyexistingdirectory //\attacker.com/../../../anyexistingdirectory -> /attacker.com/../../../anyexistingdirectory \//\attacker.com/../../../anyexistingdirectory -> /attacker.com/../../../anyexistingdirectory And according to these test cases there was no redirection issued from the server after implementing the fix. https://bugs.python.org/issue43223
Open Graph Description: 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....
X Description: 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....
Opengraph URL: https://github.com/python/cpython/pull/24848
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:133a94fe-3ff0-4ff2-2a14-cd91d7a639d3 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | A100:D449A:1D0B2E8:25A4A7B:696B3CAE |
| html-safe-nonce | 77711fbe4b8ce50fc7979cc90f0e11a87c07ca302d9ce7a332d0cadc3e9c5b96 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTAwOkQ0NDlBOjFEMEIyRTg6MjVBNEE3Qjo2OTZCM0NBRSIsInZpc2l0b3JfaWQiOiI2MDQ4MDc1MDQ4NTExMjkwNTQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 245f5212b9c34b6d62d5cead6aed02b5c7e0771cd30c149c431571a35c55c7b5 |
| hovercard-subject-tag | pull_request:592426690 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/24848/checks |
| twitter:image | https://avatars.githubusercontent.com/u/10194373?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/10194373?s=400&v=4 |
| og:image:alt | 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.... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width