This commit is contained in:
Anric 2026-03-16 10:18:47 +08:00 committed by GitHub
commit dc89985d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 1 deletions

View file

@ -351,7 +351,8 @@
"search_engine": "search_std", "search_engine": "search_std",
"max_results": 5 "max_results": 5
}, },
"fetch_limit_bytes": 10485760 "fetch_limit_bytes": 10485760,
"allow_private_hosts": false
}, },
"cron": { "cron": {
"enabled": true, "enabled": true,

View file

@ -117,6 +117,9 @@ func registerSharedTools(
registry *AgentRegistry, registry *AgentRegistry,
provider providers.LLMProvider, provider providers.LLMProvider,
) { ) {
// Apply global settings that affect tool behavior.
tools.SetAllowPrivateWebFetchHosts(cfg.Tools.Web.AllowPrivateHosts)
for _, agentID := range registry.ListAgentIDs() { for _, agentID := range registry.ListAgentIDs() {
agent, ok := registry.GetAgent(agentID) agent, ok := registry.GetAgent(agentID)
if !ok { if !ok {

View file

@ -694,6 +694,9 @@ type WebToolsConfig struct {
// For authenticated proxies, prefer HTTP_PROXY/HTTPS_PROXY env vars instead of embedding credentials in config. // For authenticated proxies, prefer HTTP_PROXY/HTTPS_PROXY env vars instead of embedding credentials in config.
Proxy string `json:"proxy,omitempty" env:"PICOCLAW_TOOLS_WEB_PROXY"` Proxy string `json:"proxy,omitempty" env:"PICOCLAW_TOOLS_WEB_PROXY"`
FetchLimitBytes int64 `json:"fetch_limit_bytes,omitempty" env:"PICOCLAW_TOOLS_WEB_FETCH_LIMIT_BYTES"` FetchLimitBytes int64 `json:"fetch_limit_bytes,omitempty" env:"PICOCLAW_TOOLS_WEB_FETCH_LIMIT_BYTES"`
// AllowPrivateHosts controls whether web_fetch may connect to local/private IPs.
// Defaults to false to reduce SSRF exposure.
AllowPrivateHosts bool `json:"allow_private_hosts" env:"PICOCLAW_TOOLS_WEB_ALLOW_PRIVATE_HOSTS"`
} }
type CronToolsConfig struct { type CronToolsConfig struct {

View file

@ -412,6 +412,7 @@ func DefaultConfig() *Config {
}, },
Proxy: "", Proxy: "",
FetchLimitBytes: 10 * 1024 * 1024, // 10MB by default FetchLimitBytes: 10 * 1024 * 1024, // 10MB by default
AllowPrivateHosts: false,
Brave: BraveConfig{ Brave: BraveConfig{
Enabled: false, Enabled: false,
APIKey: "", APIKey: "",

View file

@ -788,6 +788,12 @@ func NewWebFetchTool(maxChars int, fetchLimitBytes int64) (*WebFetchTool, error)
// This is false in normal runtime to reduce SSRF exposure, and tests can override it temporarily. // This is false in normal runtime to reduce SSRF exposure, and tests can override it temporarily.
var allowPrivateWebFetchHosts atomic.Bool var allowPrivateWebFetchHosts atomic.Bool
// SetAllowPrivateWebFetchHosts configures whether the web_fetch tool may access local/private IPs.
// This is normally false to reduce SSRF attack surface.
func SetAllowPrivateWebFetchHosts(allow bool) {
allowPrivateWebFetchHosts.Store(allow)
}
func NewWebFetchToolWithProxy(maxChars int, proxy string, fetchLimitBytes int64) (*WebFetchTool, error) { func NewWebFetchToolWithProxy(maxChars int, proxy string, fetchLimitBytes int64) (*WebFetchTool, error) {
if maxChars <= 0 { if maxChars <= 0 {
maxChars = defaultMaxChars maxChars = defaultMaxChars