Repository navigation
Conversation
20 of 32 tasks
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.
Summary
When SSRF protection was enabled (production +
SSRF_PROTECTION_ENABLED=true),NewOutboundHTTPTransportsettransport.Proxy = nil, silently ignoringHTTP_PROXY/HTTPS_PROXY/NO_PROXY. Deployments that must egress through a proxy (corporate egress proxy, local Clash/Surge, restricted networks) had to choose between SSRF protection and working outbound requests for models, embeddings, MCP, OCR, identity providers, etc.Root cause: Go's
Transportdials the proxy through the sameDialContexthook that hosts the SSRF guard, so a loopback/private proxy address (e.g.127.0.0.1:7890) was rejected as an unsafe target, while the real target was never visible to the dialer.This PR keeps the standard proxy variables working under SSRF protection without adding any config option:
Transport.Proxy(validatingProxy): every request, including each redirect hop, is checked against the activeOutboundPolicybefore a proxy is selected. Metadata, link-local, private literals and user-endpoint (public-only) restrictions still apply.allowProxyDial): only the literalhost:portfrom the proxy URL bypasses the guarded dialer; other hosts resolving to the same IP are still checked.validateProxiedTargetHost), since the proxy resolves the target itself:inet_aton-style resolvers treat as IPv4 (127.1,2130706433,0x7f000001,0177.0.0.1);127.0.0.1.nip.io); if local resolution fails, the request is left to the proxy.NO_PROXYhits and loopback targets keep the existing resolve → validate → dial-validated-IP path.sync.OnceValue), shared by proxy selection, the dial allowance and startup logging.outbound_proxy_enabled(proxy URLs reduced toscheme://host:port, no credentials),outbound_proxy_disabled, or warnsoutbound_proxy_ignoredwhen only the unsupportedALL_PROXYis set.user:pass@) are stripped before validation only, so fixed URLs such asGEOIP_DATABASE_URLwith embedded credentials are not rejected; the outgoing request is unchanged.golang.org/x/netmoves from indirect to direct (http/httpproxy). The signature ofNewOutboundHTTPTransportis unchanged; no call sites change. Adds a read-onlyOutboundPolicy.Enforced()accessor for the startup log.Change type
Affected areas
Verification
New tests in
backend/internal/shared/security/outbound_proxy_test.go:Not verified manually against a real Clash / corporate proxy and model upstream.
Screenshots, API examples, or logs
Configuration, migration, and compatibility notes
HTTP_PROXY/HTTPS_PROXY/NO_PROXYenvironment variables; changes require a restart.ALL_PROXYis not supported (Go's standard library does not read it). For SOCKS, setHTTP_PROXY/HTTPS_PROXYto asocks5://URL.http://1.1/) are rejected when proxied.Documentation
README.mdanddocs/README.zh-CN.md: newHTTP_PROXY/HTTPS_PROXY/NO_PROXYrow in the environment variable table and a paragraph in the SSRF section.Security and privacy
Checklist
.pycfiles,.envfiles, and local storage data are not committed.