-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Fixed rebuild_safe_url function #3832
base: main
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍(Review updated until commit 0ae056d)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨ |
Persistent review updated to latest commit 0ae056d |
PR Code Suggestions ✨ |
This fixes the issue for the rebuild_safe_url which was introducing SSRF vulnerabilities in the /website/views/issue.py at file issues.py and company.py by improperly sanitizing the url. My changes to the code bring enhanced protection from SSRF, CRLF and path traversal vulnerabilities by properly sanitizing and blocking requests to internal ip address. The dns_safe is another function added which first resolves the input url from the user and then resolves it's ip address before processing it any further [Protects from dns rebinding] . It is advisable to use this version of rebuild_safe_url wherever there;s a need to take user input. |
@DonnieBLT I have added the test case, please check if any improvements are needed or edge case I might've missed. |
Can this be merged? @DonnieBLT |
User description
Now the rebuild_safe_url checks for potential ssrf payload and returns None in case such url is provided, also I have made the path sanitization better since the previous one only removed the query and fragment part from the path but now it checks furtherfor carriage return and line feed and other misused paths and normalizes them.
fixes #3797
fixes #3923
PR Type
Bug fix, Tests
Description
Enhanced
rebuild_safe_url
to sanitize URLs against SSRF vulnerabilities.Added
is_dns_safe
function to validate DNS safety of URLs.Introduced comprehensive test cases for
rebuild_safe_url
function.Removed deprecated
is_safe_url
function to streamline URL validation.Changes walkthrough 📝
test_api.py
Add test cases for `rebuild_safe_url` function
website/test_api.py
RebuildSafeUrlTestCase
.rebuild_safe_url
.traversal.
utils.py
Improve URL sanitization and add DNS safety checks
website/utils.py
rebuild_safe_url
to sanitize URLs against SSRFvulnerabilities.
is_dns_safe
function to validate DNS safety of hostnames.rebuild_safe_url
.is_safe_url
function.