Skip to content

fix(#1105): allow custom_providers hostnames through SSRF check#1113

Closed
bergeouss wants to merge 1 commit intonesquena:masterfrom
bergeouss:fix/1105-ssrf-local-custom-providers
Closed

fix(#1105): allow custom_providers hostnames through SSRF check#1113
bergeouss wants to merge 1 commit intonesquena:masterfrom
bergeouss:fix/1105-ssrf-local-custom-providers

Conversation

@bergeouss
Copy link
Copy Markdown
Contributor

Thinking Path

  • SSRF check blocks requests to private IPs unless hostname is in a hardcoded allowlist
  • Only ollama, localhost, 127.0.0.1, lmstudio, lm-studio are allowed
  • Users with llama.cpp, llama-swap, vLLM, TabbyAPI, or any custom hostname resolving to a private IP are blocked
  • These are user-explicitly configured endpoints in custom_providers — not SSRF risks
  • Fix: extract hostnames from custom_providers[].base_url and add them to the trusted set before the SSRF check

What Changed

  • api/config.py: Before the SSRF check in _build_available_models_uncached(), build a _ssrf_trusted_hosts set from all custom_providers[].base_url entries. The is_known_local check now also accepts any hostname in this set. The original hardcoded allowlist is unchanged.

Why It Matters

Users running local inference servers (llama.cpp, vLLM, TabbyAPI, llama-swap) with custom hostnames get SSRF: resolved hostname to private IP errors. Their models never appear in the dropdown. After this fix, any endpoint explicitly configured in custom_providers is trusted.

Verification

  • pytest tests/test_issue1105_ssrf_custom_providers.py -v — 7/7 pass
  • pytest tests/test_model_resolver.py tests/test_custom_provider_display_name.py -v — 26/27 pass (1 pre-existing failure)
  • Syntax check: py_compile api/config.py — OK

Security Note

This does NOT weaken SSRF protection. The trusted hostnames come exclusively from custom_providers in config.yaml — a file the server admin controls. Unknown private IPs are still blocked.

Risks / Follow-ups

Model Used

  • Provider: zai
  • Model: glm-5-turbo
  • Tools: Hermes Agent

Closes #1105

- Build trusted hostname set from custom_providers[].base_url in config.yaml
- These are user-explicitly configured endpoints — not SSRF risks
- Hardcoded allowlist (ollama, localhost, 127.0.0.1, lmstudio) still active
- Unknown private IPs still blocked
- Add 7 tests (5 source analysis + 2 functional with mocked socket)
@nesquena-hermes nesquena-hermes added bug Something isn't working merge soon Reviewed and queued for next release batch labels Apr 26, 2026
@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Merged in v0.50.221 via PR #1117. Thank you @bergeouss — great contribution (SSRF custom providers fix)! 🎉

1 similar comment
@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Merged in v0.50.221 via PR #1117. Thank you @bergeouss — great contribution (SSRF custom providers fix)! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working merge soon Reviewed and queued for next release batch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSRF check blocks legitimate local-network custom providers from model auto-detection

2 participants