Repository navigation
feat(proxy): FIPS-compliant encryption and password hashing - #28729
Closed
yassin-berriai wants to merge 5 commits into
Closed
yassin-berriai wants to merge 5 commits into
yassin-berriai wants to merge 5 commits into
Conversation
…8683) * fix(team): refresh team cache on team_model_add/delete (LIT-3244) team_model_add and team_model_delete wrote to the DB but did not invalidate the in-memory LiteLLM_TeamTableCachedObj used by common_checks. After the v1.83.14 common_checks centralization made team.models authoritative on /v1/files and /v1/vector_stores/*, adding a Team-BYOK model silently failed to grant the new public model name to team members until the cache TTL expired (and a removed model kept working until then on the symmetric path). Extract the cache-refresh snippet from update_team into a small helper and apply it consistently at all three team-write sites. * test: also assert updated models in team-cache-refresh pin Strengthens the LIT-3244 regression test to also assert `call_kwargs["team_table"].models` matches the updated row, not just `team_id`. Both `existing_team` and `updated_team` share `team_id` in the test setup, so the previous assertion would have passed even if the implementation accidentally cached the pre-mutation row. Greptile review feedback. * fix(team): hydrate object_permission on cache-refreshing team updates The Prisma update calls in update_team, team_model_add, and team_model_delete returned a team row with object_permission_id set but object_permission=None (the relation was not requested via include=). _refresh_cached_team then wrote that to the in-memory LiteLLM_TeamTableCachedObj, and the cache-hit path in get_team_object returns the cached object without re-hydrating. Downstream consumers (validate_key_search_tools_against_team, the MCP/agent authz paths) treat a missing object_permission as no team-level restriction, so a team-write op silently dropped object-permission enforcement until the cache TTL expired or a DB-fetch path re-hydrated it. Add include={"object_permission": True} to all three updates so the refresh writes a complete cached team. Extend the LIT-3244 regression test to pin both the cached object_permission and the include shape on the Prisma call. Surfaced in PR review of LIT-3244.
… Anthropic (#28723) `getProviderModels()` matched a model into a provider's dropdown when the model's `litellm_provider` string *contained* the provider key as a substring. The intent was to admit suffix variants (e.g. `anthropic_text`, `bedrock_converse`), but the substring check is too loose: it also pulls in unrelated providers whose name happens to contain the key, most visibly `vertex_ai-anthropic_models` matching `anthropic` and `vertex_ai-openai_models` matching `openai`. Replace `.includes()` with separator-anchored prefix matching (`startsWith(provider + "_")` / `startsWith(provider + "-")`). All legitimate variants in `model_prices_and_context_window.json` still match (`anthropic_text`, `azure_text`, `azure_ai`, `bedrock_converse`, `bedrock_mantle`, `cohere_chat`, `fireworks_ai-embedding-models`, `vertex_ai-*`, `vertex_ai_beta`), and the cross-provider leak is closed. Tests: update one assertion that pinned the buggy substring behavior (`custom_openai_endpoint` matching `openai` — not a real provider value); add 6 new tests covering the leak regressions and the variant-preservation contract for vertex_ai/bedrock/fireworks.
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: ryan-crabbe-berri <ryan-crabbe-berri@users.noreply.github.com>
…3317) Replace pynacl (XSalsa20-Poly1305, not FIPS-approved) with AES-256-GCM from the `cryptography` library (OpenSSL-backed, FIPS 140-2/3 compliant) when LITELLM_FIPS_MODE=true is set. Replace scrypt password hashing with PBKDF2-HMAC-SHA256 (NIST SP 800-132 approved, 600 000 iterations) in FIPS mode. Full backward compatibility is maintained: legacy nacl-encrypted values and scrypt/SHA256 password hashes are still readable in all modes, and migration to the new algorithm happens automatically on next login. - encrypt_value_helper: emits `aes256gcm:<b64>` when FIPS mode is on - decrypt_value_helper: routes on prefix; nacl fallback for legacy values - hash_password: emits `pbkdf2:…` in FIPS mode, `scrypt:…` otherwise - verify_password: supports pbkdf2, scrypt, and SHA256 (legacy) formats - _rehash_password_if_needed: upgrades to current algorithm on login - migrate_passwords_to_scrypt_async: skips pbkdf2-prefixed hashes - 48 new unit tests covering all modes and cross-format compatibility https://claude.ai/code/session_01PfHdZL7eNSDDfJsv4Bcyx1
|
|
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| UserAPIKeyAuth, | ||
| ) | ||
| from litellm.proxy.auth.auth_checks import ( | ||
| _cache_team_object, |
Comment on lines
+4604
to
+4608
| from litellm.proxy.proxy_server import ( | ||
| prisma_client, | ||
| proxy_logging_obj, | ||
| user_api_key_cache, | ||
| ) |
Comment on lines
+4691
to
+4695
| from litellm.proxy.proxy_server import ( | ||
| prisma_client, | ||
| proxy_logging_obj, | ||
| user_api_key_cache, | ||
| ) |
…rd_if_needed Define _is_fips_mode directly in proxy/utils.py (uses only stdlib `os`) instead of lazily importing it from encrypt_decrypt_utils, which created a cyclic import chain detected by CodeQL (utils → encrypt_decrypt_utils → proxy_server → utils). Import _is_fips_mode from proxy/utils in login_utils to match. https://claude.ai/code/session_01PfHdZL7eNSDDfJsv4Bcyx1
|
Hi @yassin-berriai , |
6 tasks done
devin-ai-integration
Bot
deleted the
litellm_fix/fips-compliant-encryption
branch
September 10, 2026 03:41
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
Resolves LIT-3317 | Closes #16789
LiteLLM currently uses pynacl (libsodium / XSalsa20-Poly1305) for credential encryption and scrypt for password hashing. Neither algorithm is FIPS 140-2/3 approved, which blocks deployment in FIPS-restricted environments.
This PR adds full FIPS compliance via a single environment variable:
LITELLM_FIPS_MODE=true.What changes
LITELLM_FIPS_MODE=true)cryptography(OpenSSL)Backward compatibility
aes256gcm:prefix and are readable in non-FIPS mode too.verify_passwordsupportspbkdf2:,scrypt:, and legacy SHA-256 formats. On next login,_rehash_password_if_neededautomatically upgrades to the current algorithm.migrate_passwords_to_scrypt_asyncskips already-hashedpbkdf2:passwords.No new dependencies
cryptography(already pinned at46.0.7) is used for AES-256-GCM.hashlib.pbkdf2_hmacis stdlib.pynaclis still present for reading legacy encrypted values.Behavioral test matrix
aes256gcm:<b64>aes256gcm:…InvalidTagValueErrorscrypt:…pbkdf2:…scrypt:…pbkdf2:…scrypt:…pbkdf2:…scrypt:…pbkdf2:…pbkdf2:…scrypt:…scrypt:…LITELLM_FIPS_MODEdetectiontrue/1/yesLITELLM_FIPS_MODEdetectionfalse/0/unset48 unit tests, all passing.
Test plan
uv run pytest tests/test_litellm/proxy/auth/test_fips_compliance.py -v→ 48 passeduv run pytest tests/test_litellm/proxy/auth/test_password_hashing.py tests/test_litellm/proxy/auth/test_login_utils.py -v→ 27 passed (existing tests unchanged)uv run ruff check→ no issuesuv run black→ no issueslitellm/proxy/_experimental/out/https://claude.ai/code/session_01PfHdZL7eNSDDfJsv4Bcyx1
Generated by Claude Code