config: validate OPENAI_API_BASE against SSRF risks#367
Merged
Conversation
Signed-off-by: SAY-5 <saiasish.cnp@gmail.com>
tbckr
approved these changes
May 5, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #367 +/- ##
==========================================
+ Coverage 75.80% 78.80% +2.99%
==========================================
Files 20 21 +1
Lines 1298 1151 -147
==========================================
- Hits 984 907 -77
+ Misses 226 155 -71
- Partials 88 89 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 13, 2026
tbckr
added a commit
that referenced
this pull request
May 13, 2026
PR #367 enforced https-only on OPENAI_API_BASE to close #358, which broke local LLM setups (Ollama, LiteLLM, vLLM in containers) that legitimately use plain http on loopback or private networks. The validator now accepts: - https for any host (unchanged) - http for localhost, 127.0.0.0/8, ::1, RFC1918 (10/8, 172.16/12, 192.168/16) and RFC4193 ULA (fc00::/7) Link-local (169.254/16 IMDS, fe80::/10) and 0.0.0.0/8 are rejected explicitly so the IMDS exfiltration vector from #358 stays blocked. Single-label LAN hostnames (e.g. http://thinkbox:8080/v1) can't be classified by IP literal and need an explicit opt-out via the new --insecure-api-base persistent flag or insecureAPIBase: true in config.yaml. The opt-out is deliberately not bound to an env var: #358's threat model assumes attacker control of the environment, so an env-var opt-out would undo the validation guarantee. When validation passes, the override is logged at debug instead of warn (PR #367 emitted a warn line per request, which interleaved with stderr in scripts). Closes #371.
tbckr
added a commit
that referenced
this pull request
May 13, 2026
PR #367 enforced https-only on OPENAI_API_BASE to close #358, which broke local LLM setups (Ollama, LiteLLM, vLLM in containers) that legitimately use plain http on loopback or private networks. The validator now accepts: - https for any host (unchanged) - http for localhost, 127.0.0.0/8, ::1, RFC1918 (10/8, 172.16/12, 192.168/16) and RFC4193 ULA (fc00::/7) Link-local (169.254/16 IMDS, fe80::/10) and 0.0.0.0/8 are rejected explicitly so the IMDS exfiltration vector from #358 stays blocked. Single-label LAN hostnames (e.g. http://thinkbox:8080/v1) can't be classified by IP literal and need an explicit opt-out via the new --insecure-api-base persistent flag or insecureAPIBase: true in config.yaml. The opt-out is deliberately not bound to an env var: #358's threat model assumes attacker control of the environment, so an env-var opt-out would undo the validation guarantee. When validation passes, the override is logged at debug instead of warn (PR #367 emitted a warn line per request, which interleaved with stderr in scripts). Closes #371.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validates OPENAI_API_BASE as an absolute https URL with a non-empty host before applying it; without this, a hostile env var or config file silently redirects the Authorization: Bearer header to an attacker-controlled endpoint. The check is hostname-agnostic to preserve compatibility with Azure OpenAI, OpenRouter, and self-hosted backends fronted by TLS.
Closes #358.