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/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b8925a22-c2c0-c33c-de59-7ce78b88c867 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D76C:2304CD:4495D9:600445:696A4734 |
| html-safe-nonce | 3032eb91a10ad9c6ea6d295ecf6c67912559d5c96e223218aface7207ef14031 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzZDOjIzMDRDRDo0NDk1RDk6NjAwNDQ1OjY5NkE0NzM0IiwidmlzaXRvcl9pZCI6Ijg0NjEzMDYyMjg4MzM0MDQ3MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1438cef2eb1e1ccc702cd10327755f76917d962604cfcc629fd7a7184f7db53f |
| hovercard-subject-tag | pull_request:592426690 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/files |
| 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 | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width