mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-03 01:38:46 +00:00
4.1 KiB
4.1 KiB
| name | description |
|---|---|
| rust-credential-boundary | Add or change outbound credential and resource provenance checks in litellm-rust, or the host code that labels where request inputs came from, so a request can never steer a host-owned credential to a caller-chosen endpoint, scope, project or space |
Rust credential boundary
A request must never pair a resource it controls, such as api_base, scope, project_id or space_id, with a credential the host owns. Three layers decide this, and only the last one is Rust
- Edge filter, in the Python proxy for every route
is_request_body_safeinlitellm/proxy/auth/auth_utils.pyrejects caller fields by name, such asapi_baseandbase_urlgeneral_settings.allow_client_side_credentialsor a model group'sconfigurable_clientside_auth_paramslet them through, checked against the model name the caller sent, before alias resolution- When a caller
api_baseis allowed,litellm/router_utils/clientside_credential_handler.pystrips the admin's provider config but keepsapi_key, because the admin vouched for that destination
- Labeling, in the host
- The host records who supplied each input as
InputSourceonSourced<T> - Only routes that reach Rust have labels. Python-only routes have none
- The host records who supplied each input as
- Enforcement, in
CredentialBoundary(crates/auth-types/src/boundary.rs)newaccepts a credential bundle that is all request-owned or all host-owned, andhost_onlyalso rejects request-owned bundlesvalidate_resourcesrejects any request-owned resource once the credentials are host-owned- It trusts labels completely. A wrong label passes, and a missing label means
Deployment
Providers
- Pass every credential component to
CredentialBoundary::new- Use
host_onlyfor ambient identities, client assertions and host file references
- Use
- Pass every protected resource to
validate_resources- The endpoint, issuer or authority, audience or scope, and project or space
- Every alias and nested spelling, before precedence resolution drops one. An equal request value is still request-owned
- Run the check before credential acquisition or any provider IO
- Map
UntrustedCredentialContextonto the provider's existing public error, so accepted combinations and messages stay the same - References are
crates/auth-azure/src/native.rsandcrates/llms/src/azure_ai/common_utils.rs
Hosts
- Every field the caller sent is
Request, including nested fields, aliases and connection headers- HTTP input never carries a label or an authorization flag
- Deployment config and in-process SDK callers are
Deployment, and environment lookups areEnvironment
- Relabeling a caller field as
Deploymentbecause an admin opt-in allows it is the risky step- It expresses "the admin trusts where this sends the key", which is legitimate only when decided against the deployment that actually serves the request
- Deciding it from the requested model name before alias resolution lets an allowed alias borrow a protected deployment's credentials, and the boundary cannot see the wrong label
- What to do depends on the route
- Pure Rust with no Python fallback, such as tokenize
- Never relabel. Caller fields are always
Request - The edge filter still runs and is harmless redundancy
- A caller who wants to override a resource sends a full credential set
- Never relabel. Caller fields are always
- Rust with a Python fallback that must keep parity
- If the Python path honors an opt-in, the Rust labeling has to as well, or the paths diverge
- Decide it after deployment resolution from that deployment's config, or record the divergence
- Python only
- The edge filter and the field stripping are the only fence. They are name-based and inconsistent, but keep them until the route moves to Rust
- Pure Rust with no Python fallback, such as tokenize
Tests
- Cover the
InputSourcecross product for each credential component and resource with#[rstest]and#[values(...)], asserting the rule instead of a hand-listed table - Add one named case per alias or nested spelling
- Keep the provider's existing error message assertions
- On the host side, assert that a caller field stays
Requesteven when the deployment lists it inconfigurable_clientside_auth_params