Commit db06c3c
security: fix SSRF vulnerabilities in Python example scripts
This commit addresses Server-Side Request Forgery (SSRF) vulnerabilities
identified by Snyk security scan (CWE-918) in Python example scripts.
Changes:
- Added validate_host() function to validate and sanitize host parameters
- Applied validation to examples/pydantic_models_to_grammar_examples.py
- Applied validation to tools/tts/tts-outetts.py
The validation function:
- Checks for invalid characters (null bytes, whitespace, @ symbols)
- Validates URL format using urllib.parse
- Restricts to HTTP/HTTPS schemes only
- Prevents malformed or suspicious host strings
Security Impact:
- Medium severity: Prevents attackers from manipulating host parameters
to access internal services or scan internal networks
Snyk Findings:
- Rule ID: python/Ssrf
- CWE-918: Server-Side Request Forgery
- Affected files: 2 Python scripts with 3 vulnerable code paths
Link to Devin run: https://app.devin.ai/sessions/f6397deb8913436aabd4c1f234f8f8fd
Co-Authored-By: Jake Cosme <[email protected]>1 parent 661ae31 commit db06c3c
File tree
2 files changed
+92
-0
lines changed- examples
- tools/tts
2 files changed
+92
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
22 | 64 | | |
23 | 65 | | |
24 | 66 | | |
25 | 67 | | |
26 | 68 | | |
27 | 69 | | |
| 70 | + | |
28 | 71 | | |
29 | 72 | | |
30 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
9 | 51 | | |
10 | 52 | | |
11 | 53 | | |
| |||
137 | 179 | | |
138 | 180 | | |
139 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
140 | 189 | | |
141 | 190 | | |
142 | 191 | | |
| |||
0 commit comments