fix(http): allow localhost URLs for local provider types (Ollama, Claude CLI) (#674)

SSRF validation in validateProviderURL() blocked all localhost/loopback
addresses, preventing local providers like Ollama from being configured
with http://localhost:11434/v1. Introduce localProviderTypes map to skip
SSRF checks for inherently local provider types (ollama, claude_cli, acp).

Closes #673
This commit is contained in:
Duc Nguyen authored and GitHub committed 2026-04-04 07:06:34 +07:00
1 parent bed309a364
commit 2b1180f59d
1 file changed
+9 -1
+9 -1
View File
@@ -237,10 +237,18 @@ func normalizeOllamaAPIBase(p *store.LLMProviderData) {
}
}
// localProviderTypes are provider types that legitimately run on localhost
// (e.g. Ollama, Claude CLI). SSRF checks are skipped for these.
var localProviderTypes = map[string]bool{
store.ProviderOllama: true,
store.ProviderClaudeCLI: true,
store.ProviderACP: true,
}
// validateProviderURL rejects provider base URLs pointing to internal/private networks.
// Defense-in-depth: prevents SSRF when providers are later used for API calls.
func validateProviderURL(rawURL string, providerType string) error {
if rawURL == "" || providerType == store.ProviderACP {
if rawURL == "" || localProviderTypes[providerType] {
return nil
}
u, err := url.Parse(rawURL)