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

Ignore normalization URL #5289

Closed
everping opened this issue Dec 10, 2019 · 4 comments
Closed

Ignore normalization URL #5289

everping opened this issue Dec 10, 2019 · 4 comments

Comments

@everping
Copy link

everping commented Dec 10, 2019

In cases I would like to test Path Traversal vulnerabilities in web applications, the target URL is usually https://example.com/../../path. Using the GET method in requests, that URL will be normalized as below. Consequently, this will lead to unintended results in the test.

r = requests.get('https://example.com/../../path')
print(r.url)
# https://example.com/path

With curl, we have an option to ignore the normalization : --path-as-is. So, do we have an equivalent option for requests?

@everping
Copy link
Author

@EDjur Thank you for your information. Do you know a workaround to resolve this?

@akmalhisyam
Copy link

Try using prepared request

url = "http://example.com/../something.txt"
s = requests.Session()
req = requests.Request(method='POST' ,url=url, headers=headers, data=data)
prep = req.prepare()
prep.url = url
r = s.send(prep, verify=False)

@everping
Copy link
Author

@akmalhisyam Thank you very much. It works well.

@nateprewitt
Copy link
Member

@akmalhisyam is correct here. Using the PreparedRequests workflow will typically solve issues like this if you MUST explicitly set something.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants