* fix(security): restrict libcurl redirect protocols to HTTPS only
Fixes SWSPLAT-24200 by adding security restrictions to all CURLOPT_FOLLOWLOCATION
usage in HttpClient to prevent SSRF, protocol downgrade attacks, and redirect-loop DoS.
Changes:
- Add CURLOPT_MAXREDIRS=5L to limit redirect chains
- Add CURLOPT_PROTOCOLS_STR="https" to restrict initial protocol
- Add CURLOPT_REDIR_PROTOCOLS_STR="https" to restrict redirect protocols
This prevents:
- HTTPS→HTTP downgrade attacks during backend binary downloads
- FTP/FILE protocol SSRF to internal network endpoints
- Infinite redirect loops causing DoS
Applied to all three locations that use CURLOPT_FOLLOWLOCATION:
1. HttpClient::get() - line 375
2. HttpClient::download_attempt() - line 683
3. HttpClient::download_attempt() HEAD request - line 842
Co-Authored-By: Claude <[email protected]>
* fix(security): harden HTTP redirects by trust boundary
Fixes SWSPLAT-24200 by splitting HttpClient security restrictions by
trust boundary so loopback backend RPC keeps working over http.
Policies (HttpSecurityPolicy):
- External hosts (HF, GitHub, release CDNs): https-only for the initial
request and every redirect hop, MAXREDIRS=5.
- Lemonade-managed loopback backends: http only, redirects disabled
entirely.
- Opt-in plaintext endpoints (cloud allow_insecure_http): http+https,
bounded redirects.
A shared helper (apply_http_security_policy) applies the curl options
and checks each setopt return value, so a restriction that fails to
apply fails closed.
Added test for HTTPS-to-HTTP protocol downgrade rejection under the
external policy.
* fix(cloud): use correct security policy for loopback provider discovery
* fix(cloud): forward allow_insecure_http to discovery in refresh_cloud_models
refresh_cloud_models checked allow_insecure_http before proceeding but
then called discover_models() without passing it, so discovery fell back
to the ExternalHttpsOnly policy and rejected loopback/opted-in http://
providers with "Unsupported protocol".
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* fix(cloud): derive discovery policy from scheme and opt-in
An HTTPS provider with a stale allow_insecure_http=true was selecting
AllowInsecureHttp, which permits redirect downgrades to http on the
Bearer-carrying discovery request. Derive the policy from both the URL
scheme and the opt-in so HTTPS providers stay HTTPS-only, extracted into
CloudServer::discovery_policy() with focused regression tests.
Also treat CURLE_UNSUPPORTED_PROTOCOL and CURLE_URL_MALFORMAT as
permanent download failures so the retry loop stops immediately and
preserves any existing partial file.
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>