Repository navigation
feat(rust): use OpenSSL for the Rust bridge's HTTPS clients in the FIPS build - #53104
yucheng-berri wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
[Medium impact] TLS behavior changes across Rust bridge HTTPS clients in FIPS builds. The code changes appear sound, but the redundant comments must be removed to meet the repository's explicit rule. Findings
|
e12e27a to
ca47528
Compare
8cff0d6 to
74d6872
Compare
ca47528 to
e74a955
Compare
74d6872 to
6ffda16
Compare
e74a955 to
f54693f
Compare
6ffda16 to
d854537
Compare
f54693f to
5ce391c
Compare
d854537 to
3498a49
Compare
5ce391c to
0c0ecd7
Compare
3498a49 to
ab8ed2f
Compare
0c0ecd7 to
aa57ad6
Compare
ab8ed2f to
11ad851
Compare
aa57ad6 to
024cde2
Compare
11ad851 to
b8666b6
Compare
21af815 to
c534365
Compare
0d20e57 to
8200486
Compare
c534365 to
917f64a
Compare
8200486 to
309ea1f
Compare
917f64a to
7f69b26
Compare
…PS build With the build switch's fips feature, the bridge installs rustls-openssl as the process rustls CryptoProvider when it loads, and litellm-http builds its TLS configs from the installed provider, so the FIPS image's bridge HTTPS calls do their crypto in the image's FIPS provider. The provider keeps ring's 2048 to 8192-bit RSA signature range. An ssl_ecdh_curve the provider does not offer is reported unsupported with one warning, so the bridge keeps its calls on the default groups. Builds without the feature keep ring.
7f69b26 to
74a91d3
Compare
…http_openssl # Conflicts: # litellm/rust/crates/python-bridge/src/lib.rs # litellm/rust/crates/python-bridge/src/logger/tests.rs
…e keeps the call on The /v1/messages client hands calls with settings rustls cannot apply to Python's transport, so it now logs only the setting it drops while keeping the call (a curve the installed provider does not offer). The standard build logs nothing new for that client, as on main. The FIPS build's RSA floor stays at 2048 bits, which is the FIPS module's own floor; the doc comment and tests now say so and cover 2047 bits.
| resolution.config | ||
| } | ||
|
|
||
| /// Logs each setting in `unsupported` this process has not warned about yet. |
There was a problem hiding this comment.
Comments repeat simple helpers
AGENTS.md permits explanatory comments only for complex logic. The new warn_once and kept_on_bridge comments restate straightforward code. Remove both before merging.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Handwritten 1-3 sentence description
[insert handwritten description here]
Details
TLDR
Problem this solves:
litellmis imported, and, whenfips_modeis off, they make the provider calls the bridge serves (for example/v1/messages). Withfips_mode: truethose calls already go through Python's clientHow it solves it:
fipsfeature (from build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917, whichDockerfile.fipsbuilds with), the bridge installsrustls-opensslas the process crypto provider when it loadslitellm-httpbuilds its TLS configs from the installed provider instead of always from ring, so those connections do their crypto in the system OpenSSL and its FIPS providerssl_ecdh_curvethe provider does not offer (X25519in the FIPS image) is not applied: the bridge's clients keep the call on the provider's default groups and log a warning. The/v1/messagesclient logs only this case: a setting rustls cannot apply at all sends the call to Python's client, which applies it, so that client stays silent as onmain. Python's client on that image has no X25519 either, so unlike a curve name rustls does not know, the call is not handed to Python. Without that check the curve filter left no key exchange group and rustls refused to build the client (no kx groups configured)Based on #53917 alone, which holds the build switch shared with #53070 and #53103, so this PR no longer depends on them or on #53097, and they merge in any order. This PR is the only one that edits the bridge's
fipsfeature line, addingdep:rustls-openssl. The head74a91d35e22has the samelitellm-httpand bridge changes as917f64aa9fc. This is item 4 of 4 for the Rust bridge's crypto in the FIPS image.User Flow
Before: an operator runs the FIPS image and the bridge's HTTPS calls still use ring
general_settings.fips_mode: truefips_modeoff, the bridge's/v1/messagescalls do the sameAfter: the same calls run their TLS in OpenSSL
/v1/messagescalls withfips_modeoffPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreNew tests, all passing on Linux:
module_import_installs_openssl_as_the_process_crypto_provider(with--features fips) next to the existing ring test, which now runs only without the featurehttp_clients_verify_with_the_installed_openssl_provider(with--features fips): a client config built from the default HTTP settings uses the OpenSSL provider's signature checks. It fails whenlitellm-httpis switched back to ringverifies_rsa_signatures_only_from_keys_in_range(with--features fips): 1024 and 2047-bit RSA are refused, 2048 and 4096 are accepted. It fails with the size check removed, and the 2047 case fails when the check rounds up to whole bytes as ring doesa_curve_is_used_only_when_the_provider_offers_it: X25519 against a provider without it is unsupported, P-256 is kepta_curve_the_provider_does_not_offer_keeps_calls_on_the_bridge: a curve the provider does not offer is left out of the settings that send calls to Python, and a curve rustls does not know stays in. It fails with the filter removednative_events_reach_python_with_levels_context_reentry_and_http_deduplicationnow also checks that the bridge's/v1/messagesclient logs nothing for a curve rustls does not know, since those calls go to Python's client. It fails when that client warns on every unsupported settingonly_a_setting_dropped_on_the_bridge_is_kept_on_it: only a curve the provider does not offer is warned about by the/v1/messagesclient and left out of the settings that send calls to Python7f69b26a0cdon build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917 alone, on Linux (74a91d35e22is the same commit on build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917's nextest commit):cargo test -p litellm-http172 passed, plus 34 in its integration tests;cargo test -p litellm-python-bridge --locked --lib505 passed and with--features fips509 passed,logger::tests::native_events_reach_python_with_levels_context_reentry_and_http_deduplicationincluded;cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--features litellm-python-bridge/fips, are clean. The bridge's Python-backed tests share one interpreter undercargo testand flake on a loaded machine: with--features fips, 6 of 23 runs had failures inworkload_identity,modify_paramsandmodel_cost::fetch, some cascading intosecrets::callbackandocr, against 2 of 8 runs on build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917 alone and 1 of 8 here without the feature. build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917 now runs the bridge's FIPS tests undercargo nextest run, one process per test, as the workspace step does68a2b66499dmerges main628e4a6fdc9in through build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917. Main's refactor(rust_bridge): give the logger module one role and split it by concern #53690 moved the bridge logger tests fromlogger/tests.rsintologger/process.rs, so this PR'smessages_warningcheck moved with them, unchanged apart from indentation, andlib.rskeeps both main's new modules andtls_provider. Therecargo test -p litellm-http172 passed plus 34;cargo nextest run -p litellm-python-bridge --locked529 of 530 passed and 533 of 534 with--features fips, the failure in both beingmarshal_boundary, which fails the same on build(rust): add the FIPS build switch the Rust bridge's OpenSSL items share #53917 with main merged in. Clippy-D warningsis clean with and without the feature. The head4636f2df5c0only drops the doc comment onprovider()inlitellm-http; there fmt, clippy both ways andcargo test -p litellm-http(172 plus 34) were rerun and pass.565fa1e31b8fixes two findings from the 11-23 gauntlet: the/v1/messagesclient now warns only about a curve the provider does not offer, and the RSA floor is documented and tested as the FIPS module's. On Linux there,cargo fmt --checkand clippy-D warningswith and without--features fipsare clean, andcargo nextest run -p litellm-python-bridgeover thehttp,tls_providerandlogger::processtests passes 38 of 38 without the feature and 42 of 42 with it. Two mutants are killed: making the/v1/messagesclient warn on every unsupported setting fails the logger test, and rounding the RSA size up to whole bytes, as ring does, fails the 2047-bit case.Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Both images were built with
docker build -f litellm/deploy/docker/Dockerfile.fips --target finalon an x86_64 VM. Before is #53103's663c4bcf2ec(fips-r3:663c4bc). After is3f99b47b4c2(fips-r4:3f99b47); the headca47528ff02only adds the HTTP client test and #53103's CI step on top. The After build log reportsPASS: all 113 ELF binaries accounted for.Dashboard on the After image, with real OpenAI and Anthropic calls
The audit proxy (After image,
fips_mode: true, 2 workers) after the audit run: a Playground call toanthropic/claude-haiku-4-5, then the Logs page with the audit's calls.The whole flow: login, Virtual Keys, Playground, Logs
Real provider calls through both images
Same rig as #53070: Postgres 16 over TLS 1.2, the proxy with 2 workers and
fips_mode: true,openai/gpt-4.1-miniandanthropic/claude-haiku-4-5with real keys, every call with its own virtual-key-authenticatedx-litellm-tagsvalue and exactly one spend row per 200./v1/messages,/v1/responses(SDK sync, async stream, curl)/v1/messagesunknown modelPGSSLKEY: chat, messages stream, responsesmethod=certThe restart row depends on where the restart lands in the burst, not on the image: the same cell cut 10 calls on Before and none on After in #53103's audit. This PR does not touch spend writing.
SSL_ECDH_CURVE=X25519withfips_modeoff: Before and the headA review of
ca47528ff02found that withfips_modeoff andSSL_ECDH_CURVE=X25519, this PR reported the curve unsupported and handed/v1/messagesto Python, whose OpenSSL on the FIPS image has no X25519 either, so those calls failed withNO_SUITABLE_GROUPSwhere Before served them from the bridge.807b3d096aakeeps those calls on the bridge on the provider's default groups.5ce391ce1ccmakes the bridge's/v1/messagesclient log that warning; before it, the proxy dropped the curve without a log line. Since565fa1e31b8, that client logs only a curve the provider does not offer, so the standard image logs nothing new.Same rig for both images: a local HTTPS model server (TLS 1.2, ChaCha20 first in its cipher order) as the deployment's
api_base, Postgres 16 over TLS, the proxy with 1 worker. Before is4fcd7ccf177(fips-apks:4fcd7cc). The head isfips-r4:917f64a, built from this PR's head917f64aa9fc, so the whole stack onmain. Its build log shows #52997's grpc and libpq check, the bridge'slibsslcheck andPASS: all 113 ELF binaries accounted for, andnm -D --undefined-only _native.abi3.solistsEVP_DigestInit_ex,EVP_sha256,EVP_PKEY_derive,SSL_CTX_newandSSL_connect. Five/v1/messagescalls and one chat call with one virtual key per config, 8 s apart, run on 2026-11-21. The earlier head imagefips-r4:5ce391cgave the same rows.4fcd7cc917f64afips_mode: false,SSL_ECDH_CURVE=X25519:/v1/messagesECDHE-RSA-CHACHA20-POLY1305ECDHE-RSA-AES256-GCM-SHA384ssl_ecdh_curve "X25519" is not offered by the FIPS build's OpenSSL provider, so the default key exchange groups are usedin the proxy logfips_mode: false, no curve:/v1/messagesECDHE-RSA-CHACHA20-POLY1305ECDHE-RSA-AES256-GCM-SHA384fips_mode: trueorfalse, no curve: chat (Python's client)ECDHE-RSA-AES256-GCM-SHA384fips_mode: true,SSL_ECDH_CURVE=X25519:/v1/messagesand chat (Python's client)NO_SUITABLE_GROUPSfor all 6 calls and the model server gets none; the client gets the 500 on eachfips_mode: false,SSL_ECDH_CURVE=X25519: chat (Python's client)Connection errorSSL_ECDH_CURVE=X25519ECDHE-RSA-CHACHA20-POLY1305ECDHE-RSA-AES256-GCM-SHA384The empty reply shows up on Before too: here on its first
fips_mode: falseX25519 call, and in earlier runs on its firstfips_mode: trueX25519 call in 2 of 4 runs. It never shows up without the curve, and the proxy logs the same status on both images, so it is not from this PR. This rig's CA now comes from a non-FIPS helper image whose certificates Python 3.13 accepts, so chat returns 200 without the curve on both images; in the earlier runs it failed on both for that rig reason.Rust TLS now runs in OpenSSL
Throwaway CA, local HTTPS servers on
python:3.13-slim(OpenSSL 3.5.7, not FIPS), so the server is free to prefer ChaCha20 or X25519. The image's OpenSSL is 4.0.3 with the FIPS provider active.nm -D --undefined-only _native.abi3.so)EVP_DigestInit_ex EVP_sha256 SSL_CTX_new SSL_connectEVP_PKEY_derive, the TLS key exchangeECDHE-RSA-CHACHA20-POLY1305ECDHE-RSA-AES256-GCM-SHA384TLS_CHACHA20_POLY1305_SHA256/v1/messagesthrough the bridge withfips_mode: false, same ChaCha20-preferring serverECDHE-RSA-CHACHA20-POLY1305ECDHE-RSA-AES256-GCM-SHA384invalid peer certificate: BadSignatureSSL_ECDH_CURVE=X25519: price list downloadSSL_ECDH_CURVE=X25519withfips_mode: true:/v1/messagesand chat with a virtual key (both on Python's client)NO_SUITABLE_GROUPSfrom Python's client, and the model server gets no request/v1/messageswithfips_mode: true(Python's client), price list download from the default GitHub URL, database TLS, client-certificate login, key hashType
🆕 New Feature
🚄 Infrastructure
Behavior changes
Removed / renamed
None.
Silent regressions to watch
peer is incompatible: ExtendedMasterSecretExtensionRequired), and the price list download falls back to the bundled copy. TLS 1.3 servers and TLS 1.2 servers that support the extension are unaffectedSSL_ECDH_CURVE=X25519(orlitellm.ssl_ecdh_curve) is not applied to the bridge's clients: the price list download and, withfips_modeoff, the bridge's/v1/messagescalls use P-256 or P-384 instead and logssl_ecdh_curve "X25519" is not offered by the FIPS build's OpenSSL provider. A server that accepts only X25519 refuses them. Withfips_mode: truethose calls already go through Python's client, which fails on this setting before and after (NO_SUITABLE_GROUPS)invalid peer certificate: BadSignature), where ring accepted it because it rounds the key size up to whole bytes. The FIPS module refuses RSA verification under 2048 bits itself (in the image,openssl dgst -sha256 -verifywith a 2041 or 2047-bit key, PKCS#1 or PSS, fails withError setting context, 2048 givesVerified OK), and Python's clients on the image already refused these keys before this PR. The price list download then falls back to the bundled copy/v1/messagesclient logs no new warning there.Cargo.lockgainsrustls-openssl, which only the feature compilesMigration for existing customers
None.
Regression tests
The tests above, plus the existing
litellm-httpsuite, which runs against ring without the feature.Caveats (if any)
Medium
rust-testjob, which runscargo test -p litellm-python-bridge --locked --features fipsafterlitellm-db --features native-tlsandlitellm-gateway-auth-core --features fips. The job runs onmainand on PRs labeledrust-tests, and this PR has the label.rust-testandrust-wheelare red on this PR for failuresmainhas on its own:marshal_boundaryflagsserde_json::from_strindb_repository/user.rs, and the wheel's stubtest reports 5 errors onNativeActiveTeamsandNativeSensitiveRoutePins. nextest stops at the first failure, so the FIPS step has not run in CI yet. The same commands pass on Linux at the head, apart from the logger test noted aboveLow
Final Attestation