Repository navigation
fix(proxy): resolve os.environ/ refs universally in DB-sourced models - #32405
Conversation
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e7c4aeb0d6ddebd948d01de3d22244c04dc331af. Configure here.
| _litellm_params[k] = self._resolve_db_litellm_param( | ||
| key=k, value=v, resolve_env_refs=resolve_env_refs | ||
| ) | ||
| _litellm_params[k] = self._resolve_db_litellm_param(key=k, value=v) |
There was a problem hiding this comment.
Rotation persists resolved env values
Medium Severity
decrypt_model_list_from_db now resolves every os.environ/ string before master-key rotation re-encrypts model params via _add_model_to_db, so DB rows that stored indirection references can be rewritten with resolved plaintext secrets. Team-scoped models previously skipped resolution on this path.
Reviewed by Cursor Bugbot for commit e7c4aeb0d6ddebd948d01de3d22244c04dc331af. Configure here.
Root cause: PR #30867 removed request-time os.environ/ expansion in BaseAWSLLM.get_credentials. That is only safe if config-load pre-resolves os.environ/ refs so the value reaching get_credentials is already the real secret. The YAML config path has always done this. The DB-load path (ProxyConfig._resolve_db_litellm_param) only re-expanded keys in a hardcoded whitelist (_DB_LITELLM_PARAM_ENV_REF_KEYS) plus short-circuited env-ref resolution entirely for team-scoped rows. PR #32256 extended that whitelist to 18 keys to unblock a customer whose Bedrock model with aws_role_name: os.environ/BEDROCK_ASSUME_ROLE_ARN broke on v1.90+, but the whitelist is structurally fragile: every future auth field breaks the same way until someone remembers to add it Fix: remove the whitelist and the team-scope short-circuit. The DB-load resolver now expands os.environ/ on every string field, matching the YAML path. Trust boundary stays on the write side: only PROXY_ADMIN can create team_id=None rows, only team admins of a team can create rows scoped to that team, and the request-body vector is still blocked by _BANNED_REQUEST_BODY_PARAMS. Team-scoped rows now resolve env refs — this is a deliberate LIT-3831 threat-model expansion trusting team admins for env-var reads Regression tests in tests/test_litellm/proxy/proxy_server/test_proxy_config.py: - test_ProxyConfig__add_deployment_resolves_env_refs_after_db_decrypt pins admin-scoped rows resolve every field (previously api_base stayed literal) - test_ProxyConfig__add_deployment_resolves_team_env_refs pins team rows resolve env refs (previously stayed literal) - test_ProxyConfig__add_deployment_resolves_env_refs_on_arbitrary_field pins the no-whitelist invariant against a made-up field name - test_ProxyConfig__add_deployment_resolves_env_refs_for_aws_bedrock_auth_params (from #32256) still passes - Path B counterparts (decrypt_model_list_from_db) mirror the above Left as followups (not fixed here): - /model/info and /v2/model/info still echo resolved values for fields not in the current pop-list (aws_role_name, aws_sts_endpoint, api_base, etc.). Fix is to extend remove_sensitive_info_from_deployment; separate PR - Master-key rotation reads DB rows via decrypt_model_list_from_db which now resolves universally, so rotation collapses env-refs into hardcoded values. Pre-existing bug for the 6 previously-whitelisted fields; wider surface after this PR. Separate PR
e7c4aeb to
5862be3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
….1) (#1475) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/berriai/litellm](https://images.chainguard.dev/directory/image/wolfi-base/overview) ([source](https://github.com/BerriAI/litellm)) | patch | `v1.91.0` → `v1.91.1` | --- ### Release Notes <details> <summary>BerriAI/litellm (ghcr.io/berriai/litellm)</summary> ### [`v1.91.1`](https://github.com/BerriAI/litellm/releases/tag/v1.91.1) [Compare Source](BerriAI/litellm@v1.91.1...v1.91.1) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.91.1/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​32256](BerriAI/litellm#32256), [#​32405](BerriAI/litellm#32405), [#​32524](BerriAI/litellm#32524) to stable/1.91.x and cut 1.91.1 by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​32552](BerriAI/litellm#32552) **Full Changelog**: <BerriAI/litellm@v1.91.0...v1.91.1> ### [`v1.91.1`](https://github.com/BerriAI/litellm/releases/tag/v1.91.1) [Compare Source](BerriAI/litellm@v1.91.0...v1.91.1) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.91.1/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​32256](BerriAI/litellm#32256), [#​32405](BerriAI/litellm#32405), [#​32524](BerriAI/litellm#32524) to stable/1.91.x and cut 1.91.1 by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​32552](BerriAI/litellm#32552) **Full Changelog**: <BerriAI/litellm@v1.91.0...v1.91.1> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/1475
….1) (#488) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/berriai/litellm](https://images.chainguard.dev/directory/image/wolfi-base/overview) ([source](https://github.com/BerriAI/litellm)) | patch | `v1.91.0` → `v1.91.1` | --- ### Release Notes <details> <summary>BerriAI/litellm (ghcr.io/berriai/litellm)</summary> ### [`v1.91.1`](https://github.com/BerriAI/litellm/releases/tag/v1.91.1) [Compare Source](BerriAI/litellm@v1.91.1...v1.91.1) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.91.1/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​32256](BerriAI/litellm#32256), [#​32405](BerriAI/litellm#32405), [#​32524](BerriAI/litellm#32524) to stable/1.91.x and cut 1.91.1 by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​32552](BerriAI/litellm#32552) **Full Changelog**: <BerriAI/litellm@v1.91.0...v1.91.1> ### [`v1.91.1`](https://github.com/BerriAI/litellm/releases/tag/v1.91.1) [Compare Source](BerriAI/litellm@v1.91.0...v1.91.1) ##### Verify Docker Image Signature All LiteLLM Docker images are signed with [cosign](https://docs.sigstore.dev/cosign/overview/). Every release is signed with the same key introduced in [commit `0112e53`](BerriAI/litellm@0112e53). **Verify using the pinned commit hash (recommended):** A commit hash is cryptographically immutable, so this is the strongest way to ensure you are using the original signing key: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/0112e53046018d726492c814b3644b7d376029d0/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` **Verify using the release tag (convenience):** Tags are protected in this repository and resolve to the same key. This option is easier to read but relies on tag protection rules: ```bash cosign verify \ --key https://raw.githubusercontent.com/BerriAI/litellm/v1.91.1/cosign.pub \ ghcr.io/berriai/litellm:v1.91.1 ``` Expected output: ``` The following checks were performed on each of these signatures: - The cosign claims were validated - The signatures were verified against the specified public key ``` *** ##### What's Changed - chore(release): backport [#​32256](BerriAI/litellm#32256), [#​32405](BerriAI/litellm#32405), [#​32524](BerriAI/litellm#32524) to stable/1.91.x and cut 1.91.1 by [@​yuneng-berri](https://github.com/yuneng-berri) in [#​32552](BerriAI/litellm#32552) **Full Changelog**: <BerriAI/litellm@v1.91.0...v1.91.1> </details> --- ### Configuration 📅 **Schedule**: (in timezone America/New_York) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNTIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI1Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.greyrock.io/greyrock-labs/home-ops/pulls/488
…nvref-gates fix(proxy): resolve os.environ/ refs universally in DB-sourced models (cherry picked from commit ec4f324)


Relevant issues
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Reproduced end-to-end against a live proxy on
litellm_kraken-remove-envref-gates@ e7c4aeb0d6, backed by real Postgres 18. Config setsstore_model_in_db: true, master keysk-1234, license viaLITELLM_LICENSEDB row shape follows the customer's setup: admin-authored (
team_id=None) Bedrock model withaws_role_nameset as an env-refBefore this PR (base commit db24027): the DB-load path resolved env refs only for keys in
_DB_LITELLM_PARAM_ENV_REF_KEYS.aws_role_nameis not on the pre-PR 6-key list; even after #32256 extends the whitelist to 18 keys, any new off-list field silently fails the same way. On the unfixed code the router receives the literalos.environ/FOO_ARBITRARYand STS rejects the AssumeRole call withValidationError: os.environ/FOO_ARBITRARY is invalidAfter this PR (e7c4aeb0d6): the router deployment holds the resolved value
Same result for a team-scoped row with
api_key: os.environ/TEAM_OPENAI_KEY. A chat completion invocation through that model reaches OpenAI with the resolved key:That is
sk-team-openai-resolvedechoed back by OpenAI, masked by OpenAI's own error format. Same shape works for arbitrary custom field names (some_future_field: os.environ/TEAM_CUSTOM_ARBITRARYresolves to"team-custom-resolved"on/v2/model/info)LIT-3831 is not reopened for the original request-body vector. A caller sending
aws_role_name: os.environ/DATABASE_URL_SECRETin the request body is still refused by the existing_BANNED_REQUEST_BODY_PARAMSgate:Write-side trust boundary is unchanged. A team_verify admin cannot write another team's rows (403), a plain internal_user cannot write any model row (403). Sensitive fields explicitly popped by
remove_sensitive_info_from_deployment(api_key,client_secret,aws_secret_access_key) are still absent from/model/infoand/v2/model/inforesponsesType
🐛 Bug Fix
Changes
Root cause: PR #30867 removed request-time
os.environ/expansion inBaseAWSLLM.get_credentials. That is only safe if the config-load path pre-resolvesos.environ/refs so the value reachingget_credentialsis already the real secret. The YAML config path has always done this. The DB-load path (ProxyConfig._resolve_db_litellm_paraminlitellm/proxy/proxy_server.py) only re-expanded keys in_DB_LITELLM_PARAM_ENV_REF_KEYSplus short-circuited resolution entirely for team-scoped rows. PR #32256 extended that whitelist to 18 keys to unblock a customer whose Bedrock model withaws_role_name: os.environ/BEDROCK_ASSUME_ROLE_ARNbroke on v1.90+. The whitelist is structurally fragile though: every future auth field breaks the same way until someone remembers to add it, which is the exact regression pattern that produced the ticket that led to #32256Fix: remove the whitelist and the team-scope short-circuit. The DB-load resolver now expands
os.environ/on every string field, matching the YAML path. Trust boundary stays on the write side: onlyPROXY_ADMINcan createteam_id=Nonerows (ModelManagementAuthChecks.can_user_make_model_call), only team admins of a given team can create rows scoped to that team, and the request-body vector is still blocked by_BANNED_REQUEST_BODY_PARAMS. Team-scoped rows now resolve env refs; this is a deliberate LIT-3831 threat-model expansion trusting team admins for env-var reads (an internal design conversation covering the tradeoff)Regression tests in
tests/test_litellm/proxy/proxy_server/test_proxy_config.py:test_ProxyConfig__add_deployment_resolves_env_refs_after_db_decryptpins admin-scoped rows resolve every field, includingapi_basewhich previously stayed literaltest_ProxyConfig__add_deployment_resolves_team_env_refspins team rows resolve env refs (previously stayed literal). Fails on unfixed code with the exact "literal not resolved" symptomtest_ProxyConfig__add_deployment_resolves_env_refs_on_arbitrary_fieldpins the no-whitelist invariant against a made-up field nametest_ProxyConfig__add_deployment_resolves_env_refs_for_aws_bedrock_auth_params(from fix(proxy): resolve os.environ/ refs for all AWS auth params in DB-sourced models #32256) still passesdecrypt_model_list_from_db) mirror the above