Skip to content

feat(proxy): warn when fips_mode starts with a Postgres password login - #53097

Open
yucheng-berri wants to merge 5 commits into
mainfrom
litellm_fips_db_password_warning
Open

yucheng-berri wants to merge 5 commits into
mainfrom
litellm_fips_db_password_warning

Conversation

@yucheng-berri

@yucheng-berri yucheng-berri commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves:

  • A Postgres password login (SCRAM) computes PBKDF2 and HMAC on the client side
  • In the FIPS image that math runs in four places, none of them the FIPS module: the Rust bridge, Prisma's engines, PgBouncer, and part of it in libpq
  • No library swap fixes all four, so the only FIPS-clean setup is to log in without a password: a client certificate, or an RDS IAM or Azure Entra token

How it solves it:

  • With fips_mode: true, each worker now logs one warning at startup when DATABASE_URL, DATABASE_URL_READ_REPLICA or DIRECT_URL carries a password and neither IAM_TOKEN_DB_AUTH nor AZURE_POSTGRESQL_AUTH is on. The two flags are read with token_auth_flag_enabled, the same parser the token refresh uses
  • DIRECT_URL is the URL the migrations log in with. Token login rewrites only DATABASE_URL, so under token login a password in DIRECT_URL still warns, and the warning says to leave DIRECT_URL unset
  • With LITELLM_PGBOUNCER_ENABLED, the workers always log in to the in-container PgBouncer with a password, even when the upstream login uses a token, so they get a PgBouncer-specific warning
  • The warning says how to switch to client-certificate login
  • It only warns. A deployment that logs in with a password keeps starting exactly as before

Based on main. It changes only Python, so it does not depend on #53917 or the Rust PRs (#53070, #53103, #53104), and they merge in any order. This is item 2 of 4 for the Rust bridge's crypto in the FIPS image.

User Flow

Before: an operator turns on fips_mode with a password in DATABASE_URL, and nothing tells them the login runs outside the FIPS module

  1. They start the FIPS image with general_settings.fips_mode: true
  2. DATABASE_URL is postgresql://postgres:<password>@db:5432/litellm?sslmode=require
  3. The proxy starts, and the logs say nothing about the database login

After: the same operator gets one warning at startup that names the fix

  1. They start the same image with the same config and URL
  2. The proxy starts as before
  3. The logs show one warning per worker: general_settings.fips_mode is on but DATABASE_URL logs in to Postgres with a password. ... Use client-certificate login instead ...
  4. They switch to client-certificate login, restart, and the warning is gone

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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 more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

uv run pytest tests/unit/proxy/common_utils/test_fips.py: 82 passed on the head. The new tests cover the warning cases (password, client certificate, a password read replica next to a client-certificate writer, a password DIRECT_URL next to a client-certificate writer or under RDS IAM or Azure Entra token login, a client-certificate DIRECT_URL, a read replica alone, no database, RDS IAM and Azure Entra set to true, 1 or yes, an unreadable flag, an unparseable URL, PgBouncer workers with each upstream login), that the message never contains the password, and that only fips_mode: true logs it.

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

A DIRECT_URL that logs in with a password

This was added after the gauntlet found that a password in DIRECT_URL got no warning, including under token login, although the migrations log in with it. The rig is Postgres 16 over TLS with hostssl all migr all scram-sha-256 and hostssl all all all cert. DATABASE_URL is a client-certificate login, and the proxy runs fips_mode: true with 1 worker and runs the migrations at startup. Before is main's FIPS image fips-mb:75f71a8, which has no warning at all. After is fips-t:39b5d94, built from 917f64aa9fc plus the fixes, with this PR's head fips.py. The 576d6b5ac06 column is from the gauntlet's 2026-11-21 run of the old stack head fips-r4:917f64a, which carries this PR's previous fips.py.

Rerun on 2026-11-23 after main 628e4a6fdc9 was merged into the PRs: Before fips-mb2:628e4a6 (main), After fips-t4:846a655 (the five PRs merged together, built the same way). Every row above came out the same on both, and the format and rotation matrix matched on all 29 rows.

Setup Before 576d6b5ac06 After
DIRECT_URL=postgresql://migr:... starts, key/generate 200; Postgres logs identity="migr" method=scram-sha-256 5 times; no warning same logins, no warning same logins; the worker logs general_settings.fips_mode is on but DIRECT_URL logs in to Postgres with a password. ... Or leave DIRECT_URL unset, so the migrations log in the way DATABASE_URL does. once
Control: no DIRECT_URL every login method=cert, no warning same same
Control: DIRECT_URL a client-certificate login every login method=cert, no warning same same

database_password_login_warning called in the After image with RDS IAM (IAM_TOKEN_DB_AUTH=True) or Azure Entra (AZURE_POSTGRESQL_AUTH=True) and a password DIRECT_URL names DIRECT_URL. With the same token login and no DIRECT_URL, it returns nothing.

Before is #53070's head 7194a822331 (fips-r1:7194a82, built with docker build -f litellm/deploy/docker/Dockerfile.fips --target final). After is acf609bfed7 (fips-r2:acf609b), built as the Before image with this PR's fips.py copied over the installed one, the only file this PR changes outside tests (sha256sum of the installed file matches the PR's). Both run on an x86_64 VM. 066faf118f8 adds the read replica check, shown in its own section below. d8192d74e91 is the same commits restacked onto #53070's 18e75c927ab, which fixes the bridge pool's handling of the database root certificate and client key files, and 98b5e2f0e98 only changes the test's log collector to a tuple. 89f596b38a9 is that restacked onto #53070's 33cd7c7369a, which brings #52997's new fips-check line for grpc and libpq. 9c31e72cd3b restacked them onto #53070's d24f3f1d42d, which is based on main with #52997 merged, and whose pool also picks up replaced or late-mounted client certificate files. The current head 576d6b5ac06 is the same commits restacked onto #53070's dd0ba7934de, which only adds a CI step. This PR's fips.py is unchanged.

Dashboard on the After image, with real OpenAI and Anthropic calls

The audit proxy (After image, fips_mode: true, password login, 2 workers) after the audit run: a Playground call to anthropic/claude-haiku-4-5, then the Logs page with the audit's calls.

Playground call on the After image

Logs page on the After image

The whole flow: login, Virtual Keys, Playground, Logs

Dashboard flow

Real provider calls and the startup warning, on 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-mini and anthropic/claude-haiku-4-5 with real keys. Every call sends its own x-litellm-tags value, and every 200 has to write exactly one spend row with that tag. Each config's database password is random, and the whole proxy log is searched for it. All 29 cells per image give the same status and the same spend rows on both images; the only difference is the warning.

Config Before After
A password login, sslmode=require: chat, /v1/messages, /v1/responses (SDK sync, async stream, curl), 5 error cases, a repeated call, a 5 KB prompt all cells match, no warning all cells match, each worker logs the warning once
B client-certificate login (hostssl all all all cert, sslidentity + sslpassword, PGSSLCERT + PGSSLKEY, no password): chat, messages stream, responses 3 of 3, every login method=cert, no warning 3 of 3, every login method=cert, no warning
C password login with a PKCS#1 PGSSLKEY: chat, messages stream, responses 3 of 3, no warning 3 of 3, each worker logs the warning once
P LITELLM_PGBOUNCER_ENABLED=true, password login upstream: chat, messages stream, responses 3 of 3, no warning 3 of 3, each worker logs the PgBouncer warning once
Database password anywhere in the proxy log, every config 0 0
Postgres paused 10 s during a 30-request mixed burst 30 of 30 return 200 30 of 30 return 200
One worker killed, then 8 requests 8 of 8, worker restarted 8 of 8, worker restarted
Proxy restarted 3 s into a 20-request burst, then chat, messages stream, responses the restart cuts all 20; 3 of 3 after the restart cuts all 20; 3 of 3 after
litellm-native and litellm-prisma ciphers ECDHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES256-GCM-SHA384

A read replica that logs in with a password

Added after the gauntlet found that a password in DATABASE_URL_READ_REPLICA got no warning when DATABASE_URL used a client certificate, although the bridge's reader pool and Prisma both log in to the replica. Postgres 16 over TLS with hostssl all reader all scram-sha-256 and hostssl all all all cert, the proxy with 2 workers and fips_mode: true, DATABASE_URL a client-certificate login. Before is #53070 (fips-r1:7194a82), acf609b is this PR before the fix, After is 066faf118f8 (fips-r2:066faf1, the Before image with this PR's fips.py).

Setup Before acf609b After
DATABASE_URL_READ_REPLICA=postgresql://reader:... starts, key/generate and key/list 200; Postgres logs identity="reader" method=scram-sha-256 from litellm-native and litellm-prisma; no warning same, no warning same logins; each worker logs general_settings.fips_mode is on but DATABASE_URL_READ_REPLICA logs in to Postgres with a password... once
no read replica (control) every login method=cert, no warning same same

The warnings as logged on After:

LiteLLM Proxy:WARNING: fips.py:171 - general_settings.fips_mode is on but DATABASE_URL logs in to Postgres with a password. The password login (SCRAM) is computed outside the FIPS module. Use client-certificate login instead: cert in pg_hba.conf, sslidentity and sslpassword in DATABASE_URL with no password, and PGSSLCERT and PGSSLKEY set to the same certificate and key. RDS IAM (IAM_TOKEN_DB_AUTH) and Azure Entra (AZURE_POSTGRESQL_AUTH) token login also avoid it.
LiteLLM Proxy:WARNING: fips.py:171 - general_settings.fips_mode is on but LITELLM_PGBOUNCER_ENABLED logs the workers in to the in-container PgBouncer with a password, and that login (SCRAM) is computed outside the FIPS module. Turn LITELLM_PGBOUNCER_ENABLED off and use client-certificate login: cert in pg_hba.conf, sslidentity and sslpassword in DATABASE_URL with no password, and PGSSLCERT and PGSSLKEY set to the same certificate and key.

Type

🆕 New Feature

Behavior changes

Removed / renamed

None.

Silent regressions to watch

  • One new WARNING log line per worker at startup, only with fips_mode: true and a password in DATABASE_URL, DATABASE_URL_READ_REPLICA or DIRECT_URL. Nothing else changes: the proxy starts and connects exactly as before

Migration for existing customers

None required. To clear the warning, switch the database login to a client certificate, RDS IAM or Azure Entra.

Regression tests

tests/unit/proxy/common_utils/test_fips.py: the warning cases above, including the read replica and DIRECT_URL, the password never appearing in the message, and the warning showing only with fips_mode: true.

Caveats (if any)

Medium

  • This warns but does not refuse. A deployment with fips_mode: true and a password login still runs the SCRAM math outside the FIPS module
    • Refusing to start would break every current fips_mode deployment that logs in with a password, so it needs its own decision

Low

  • Only a password in the user info of DATABASE_URL, DATABASE_URL_READ_REPLICA or DIRECT_URL is checked. A password supplied through PGPASSWORD, a .pgpass file or a password= query parameter is not detected
  • An external PgBouncer in front of Postgres does its own SCRAM login upstream, which this warning cannot see. The in-container one (LITELLM_PGBOUNCER_ENABLED) is covered

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@veria-ai

veria-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread litellm/proxy/common_utils/fips.py Resolved
@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with no new actionable findings.

Summary

Adds a startup warning when fips_mode is enabled and a database URL contains a password.

  • FIPS-mode startup warns about Postgres password logins.

There are no code changes since the previous review. Both earlier findings are fixed. The PgBouncer check runs before token login suppresses warnings, and the test log collector uses a tuple.

Reviews (11) · Last reviewed commit: "fix(proxy): warn under fips_mode when DI..." · Reviewed by Greptile

Comment thread litellm/proxy/common_utils/fips.py Resolved
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri
yucheng-berri force-pushed the litellm_fips_db_password_warning branch from 066faf1 to d8192d7 Compare November 20, 2026 19:56
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

1 similar comment
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri
yucheng-berri force-pushed the litellm_fips_rust_db_tls branch from 18e75c9 to 33cd7c7 Compare November 20, 2026 21:14
@yucheng-berri
yucheng-berri force-pushed the litellm_fips_db_password_warning branch from 98b5e2f to 89f596b Compare November 20, 2026 21:14
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri
yucheng-berri force-pushed the litellm_fips_db_password_warning branch 2 times, most recently from 8226e70 to fe2dccc Compare November 20, 2026 23:30
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri
yucheng-berri force-pushed the litellm_fips_rust_db_tls branch from 4b599be to d24f3f1 Compare November 21, 2026 00:22
@yucheng-berri
yucheng-berri force-pushed the litellm_fips_db_password_warning branch from ba9cdc1 to 9c31e72 Compare November 21, 2026 00:22
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@yucheng-berri
yucheng-berri force-pushed the litellm_fips_db_password_warning branch from 9c31e72 to 576d6b5 Compare November 21, 2026 01:22
Postgres password login (SCRAM-SHA-256) is computed outside the FIPS module by
the Rust bridge, Prisma's engines and libpq. With fips_mode on, the proxy now
logs a warning when DATABASE_URL carries a password and neither RDS IAM nor
Azure Entra token login is on, and names client-certificate login as the fix.
… the token refresh does

Greptile: under LITELLM_PGBOUNCER_ENABLED the workers log in to the
in-container PgBouncer with a password even when IAM or Entra token login is
on upstream, so that case now gets its own warning. Devin: the token flags
were read with str_to_bool, which misses values like 1 and yes that
token_auth_flag_enabled accepts.
…assword under fips_mode

The bridge's reader pool and Prisma both log in to the read replica, so a
password there is a SCRAM login outside the FIPS module even when
DATABASE_URL uses a client certificate.
The migrations log in with DIRECT_URL when it is set, and RDS IAM or Azure Entra token login never replaces it, so a password there is a SCRAM login outside the FIPS module. The warning now checks DIRECT_URL too, and under token login checks it alone.
@yucheng-berri
yucheng-berri force-pushed the litellm_fips_rust_db_tls branch from dd0ba79 to e99e5d9 Compare November 23, 2026 20:52
@yucheng-berri
yucheng-berri force-pushed the litellm_fips_db_password_warning branch from 576d6b5 to 54cce6b Compare November 23, 2026 20:52
@yucheng-berri
yucheng-berri changed the base branch from litellm_fips_rust_db_tls to main November 23, 2026 20:53
@yucheng-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant