feat: add SSRF protection for URL fetching

This commit is contained in:
wizardchen
2026-01-21 14:48:43 +08:00
committed by lyingbug
parent e55cbaa057
commit 2a99e2458d
3 changed files with 268 additions and 0 deletions
+6
View File
@@ -243,6 +243,12 @@ func (t *WebFetchTool) validateParams(p webFetchParams) error {
if !strings.HasPrefix(p.URL, "http://") && !strings.HasPrefix(p.URL, "https://") {
return fmt.Errorf("invalid URL format")
}
// SSRF protection: validate URL is safe to fetch
if safe, reason := utils.IsSSRFSafeURL(p.URL); !safe {
return fmt.Errorf("URL rejected for security reasons: %s", reason)
}
return nil
}