Skip to content

bug: os.environ credential bleed across conversations in multi-tenant server #3138

@csmith49

Description

@csmith49

Problem

The LLM's model_validator writes API keys and base URLs directly into os.environ. In a multi-tenant server where different conversations may use different LLM providers/keys, one conversation's credentials are visible to all others via the process environment. Combined with the modify_params race (#4 in tracking issue), a conversation could inadvertently use another tenant's credentials.

Location: llm/llm.py model_validator

Evidence

Code review of llm.py model_validator. Environment variables are the mechanism for passing credentials to litellm.

Severity: Critical

Impact of fix

Tenant isolation for credentials in multi-conversation servers.

Suggested fix

Pass credentials through litellm's function arguments or per-call configuration instead of os.environ. Medium effort (requires understanding litellm's credential passing API).

Related issues and PRs

Discovered during profiling investigation (code review), May 2026. openhands-sdk v1.19.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions