Repository navigation
feat(proxy): add LITELLM_FIPS_MODE for FIPS 140 approved crypto - #38491
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
|
No action taken on #38491 — repo and author ( |
Greptile SummaryThe PR adds an opt-in FIPS mode that uses PBKDF2-HMAC-SHA256 for password and master-key derivation and AES-256-GCM for new encrypted values
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains No blocking failure remains
|
| Filename | Overview |
|---|---|
| litellm/proxy/common_utils/fips.py | Adds environment-driven FIPS selection and shared PBKDF2 or scrypt master-key derivation |
| litellm/proxy/common_utils/encrypt_decrypt_utils.py | Forces AES-256-GCM for new writes in FIPS mode while retaining format-aware decryption |
| litellm/proxy/utils.py | Adds PBKDF2 password hashing and verification while preserving existing hash formats outside FIPS mode |
| litellm/proxy/auth/login_utils.py | Selects the current password-hash prefix according to FIPS mode when deciding whether to rehash |
| litellm/proxy/_experimental/mcp_server/outbound_credentials/bridge_credentials.py | Moves bridge signing and encryption key derivation to the shared FIPS-aware helper |
| litellm/proxy/_experimental/mcp_server/outbound_credentials/session_credentials.py | Moves MCP session signing-key derivation to the shared FIPS-aware helper |
Reviews (2): Last reviewed commit: "feat(proxy): add LITELLM_FIPS_MODE for F..." | Re-trigger Greptile
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
08faa58 to
db8ffcb
Compare
|
@greptileai please review the new head db8ffcb (squashed, includes a CI test expectation fix) |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
The raise is intentional fail-closed behavior: an explicit |
|
@yucheng-berri pls update on status for FIPS |
TLDR
Problem this solves:
How it solves it:
LITELLM_FIPS_MODE=trueenv var opts into FIPS-approved cryptoRoot cause in one sentence: under an enforced OpenSSL FIPS provider,
hashlib.scryptraisesValueError: [digital envelope routines] unsupported, which breaks proxy password hashing, verification, rehash, and MCP key derivation, while the default XSalsa20-Poly1305 at-rest encryption runs but is not a FIPS-approved algorithmUser Flow
Before: an admin running the proxy on a FIPS-enforced host cannot set user passwords
{"user_id": "...", "password": "Str0ngPass!123"}"Authentication Error, [digital envelope routines] unsupported"and the password is never storedAfter: the same admin sets
LITELLM_FIPS_MODE=trueand everything works with FIPS-approved algorithmsLITELLM_FIPS_MODE=trueon the same FIPS-enforced host/ui?login=success, and a wrong password returns 401v2:gcm:values at rest)Relevant issues
Related context: #16789, #25861 (prior draft explorations in #28729, #28730)
Linear ticket
Resolves LIT-5289
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<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 more@greptileaito re-request a review after pushing changes)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 runs were captured on a live proxy on localhost:4000 with Postgres, running under an enforced OpenSSL 3.0.2 FIPS provider (
OPENSSL_CONFwithdefault_properties = fips=yes, self-builtfips.so,openssl fipsinstallverified). The control chat completion hits the real OpenAI API. The/user/updatefixture is byte-identical across both armsBefore (cd63c7e)
Control: real chat completion succeeds
curl -s http://localhost:4000/chat/completions -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Say FIPS-CONTROL-OK and nothing else"}]}'{"id":"chatcmpl-EHPog77tVg5k5tTymBBMLzP00vbbq",...,"content":"FIPS-CONTROL-OK",...}(HTTP 200, real tokens billed)Setting a user password fails
curl -s -w '\nHTTP %{http_code}\n' http://localhost:4000/user/update -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d '{"user_id":"5c416115-a50b-4f31-8816-4bd6e07d962a","password":"Str0ngPass!123"}'{"error":{"message":"Authentication Error, [digital envelope routines] unsupported","type":"auth_error","param":"None","code":"400"}}withHTTP 400litellm.proxy.proxy_server.user_update(): Exception occured - [digital envelope routines] unsupported/ValueError: [digital envelope routines] unsupportedAfter (captured at 08faa586a2, runtime code byte-identical to tip db8ffcb; the only later change is a test expectation string)
Proxy restarted on the fixed code with
LITELLM_FIPS_MODE=true, same FIPS OpenSSL envControl: real chat completion succeeds
"Say FIPS-FIXED-OK and nothing else"{"id":"chatcmpl-EHPqpLO498yYFHB332ahosMzWWSrP",...,"content":"FIPS-FIXED-OK",...}(HTTP 200)Setting a user password succeeds and stores PBKDF2
curl ... /user/updateas Beforeselect left(password,10) from "LiteLLM_UserTable" where user_email='fips-repro@example.com';returnspbkdf2:FysUI login verifies the PBKDF2 hash
curl -s -o /dev/null -w 'HTTP %{http_code} redirect=%{redirect_url}\n' -X POST http://localhost:4000/login -d "username=fips-repro@example.com&password=Str0ngPass!123"returnsHTTP 303 redirect=http://localhost:4000/ui?login=successpassword=WrongPassreturnsHTTP 401Credential written at rest with AES-256-GCM
curl -s -w '\nHTTP %{http_code}\n' http://localhost:4000/credentials -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d '{"credential_name":"fips-test-cred","credential_info":{},"credential_values":{"api_key":"sk-fips-demo-123"}}'returns{"success":true,...}withHTTP 200select credential_name, left(credential_values::text,60) from "LiteLLM_CredentialsTable" ...returnsfips-test-cred|{"api_key": "v2:gcm:EDX194oCxoGDwd-2qjuXFMbMGqWxU2R1GPmVzTCiLegacy scrypt hash fails closed with an actionable error
scrypt:hash, thencurl ... POST /loginwith the correct password returnsHTTP 401Cannot verify a scrypt password hash under LITELLM_FIPS_MODE: scrypt is not FIPS-approved. Reset this user's password so it is re-hashed with PBKDF2-HMAC-SHA256.Type
🆕 New Feature
Caveats (if any)
Medium
scrypt:password hashes cannot verify under FIPS mode; admins must reset those passwords (fails closed with a log naming the fix)LITELLM_FIPS_MODEchanges the MCP master-key KDF, invalidating outstanding MCP bridge/session tokens minted under the other modeLow
_experimental/mcp_server/outbound_credentials/envelope.py) still uses libsodium SecretBox directly; it runs fine under FIPS enforcement but is outside the approved-algorithm boundary, left for a follow-up since changing it alters the envelope wire format/user/update(hash),/login(verify), and/credentials(encrypt);/user/newignores the password field entirely, and invitation onboarding plus the startup plaintext migration reuse the samehash_passwordchokepoint fixed hereFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/c5c84e8fc1a64efebc61816ad93510a3
Open in Devin Desktop: https://app.devin.ai/desktop/session/c5c84e8fc1a64efebc61816ad93510a3?variant=devin
Requested by: @yassin-berriai