feat: implement SSRF-safe HTTP client
Add SSRF protection by validating redirect targets and resolved IPs, blocking internal hostnames, restricted suffixes, and private IP ranges including Docker and Kubernetes internal endpoints.
This commit is contained in:
@@ -74,11 +74,13 @@ type WebFetchTool struct {
|
||||
|
||||
// NewWebFetchTool creates a new web_fetch tool instance
|
||||
func NewWebFetchTool(chatModel chat.Chat) *WebFetchTool {
|
||||
// Use SSRF-safe HTTP client to prevent redirect-based SSRF attacks
|
||||
ssrfConfig := utils.DefaultSSRFSafeHTTPClientConfig()
|
||||
ssrfConfig.Timeout = webFetchTimeout
|
||||
|
||||
return &WebFetchTool{
|
||||
BaseTool: webFetchTool,
|
||||
client: &http.Client{
|
||||
Timeout: webFetchTimeout,
|
||||
},
|
||||
BaseTool: webFetchTool,
|
||||
client: utils.NewSSRFSafeHTTPClient(ssrfConfig),
|
||||
chatModel: chatModel,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user