Security: Fix SSRF vulnerabilities in Python example scripts (Snyk findings) #27
+92
−0
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.
Summary
Make sure to read the contributing guidelines before submitting a PR
This PR addresses Server-Side Request Forgery (SSRF) vulnerabilities (CWE-918) identified by Snyk security scan in two Python example scripts. The vulnerabilities allowed unsanitized command-line input to flow directly into HTTP requests, potentially enabling attackers to manipulate host parameters for malicious purposes.
Changes
Added input validation to prevent SSRF attacks in:
examples/pydantic_models_to_grammar_examples.py
tools/tts/tts-outetts.py
Implementation Details
Created
validate_host()
function that:urllib.parse
@
symbols)Security Context
Snyk Findings:
python/Ssrf
Attack Vector: Malicious actors could manipulate command-line host parameters to access internal services, scan internal networks, or exfiltrate data from non-public endpoints.
Review Checklist
[::1]:8080
)localhost:8080
127.0.0.1:8080
my-server.local:8080
http://localhost:8080
(with explicit scheme)Testing
Link to Devin run: https://app.devin.ai/sessions/f6397deb8913436aabd4c1f234f8f8fd
Requested by: Jake Cosme (@jakexcosme)