Fix SSRF vulnerability in /verify_end_point by validating endpoint URLs (#1476)#1502
Open
ACHYUTH1203 wants to merge 3 commits intoTransformerOptimus:mainfrom
Open
Fix SSRF vulnerability in /verify_end_point by validating endpoint URLs (#1476)#1502ACHYUTH1203 wants to merge 3 commits intoTransformerOptimus:mainfrom
ACHYUTH1203 wants to merge 3 commits intoTransformerOptimus:mainfrom
Conversation
Author
|
Added unit tests for the SSRF protection logic in is_safe_url. The tests cover key scenarios including valid external URLs, localhost addresses, internal/private IP ranges, and restricted schemes such as file://. To ensure test isolation and avoid dependency issues, external modules (e.g., HuggingFace and config-related imports) are mocked. This allows the tests to run independently without requiring the full application environment. Please let me know if any additional edge cases or test scenarios should be included. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enhances the security validation logic for URL handling and adds comprehensive unit tests to ensure correct behavior.
From a user perspective, this change improves the system’s ability to safely handle URLs by preventing unsafe or potentially malicious inputs (such as localhost, internal IP ranges, or restricted schemes like
file://). This reduces the risk of SSRF (Server-Side Request Forgery) vulnerabilities when processing external URLs.In addition to the validation improvements, this PR introduces isolated unit tests that verify the correctness of the URL safety logic without requiring the full application environment or heavy dependencies.
Related Issues
Solution and Design
The solution focuses on improving and validating the
is_safe_urlhelper function.Key Improvements:
127.0.0.1,localhost).192.168.x.x,10.x.x.x).file://.tests/unit_tests/helper/test_models_helper_security.py.Test Plan
The following test cases were added and validated:
Execution steps:
Run the test module using the Python module flag to ensure correct environment mapping:
Type of Change
Checklist