Is litellm safe?
- Python dynamic code execution
- Python shell/command execution
- Embedded secret / credential
What to do: Nothing here argues against installing it. Grant the capabilities it lists only if you expect the tool to need them.
litellm is a PyPI package analyzed by SkillTotal's deterministic static scanner. The scan found no malicious indicators, though 1 risky construct is reported for review. It can: delegated authentication, dynamic code execution, filesystem read, filesystem write, mcp tools detected, network egress, scoped identity and shell execution — capabilities are what the code can do, not a verdict on intent. Risk score 10/100 (low).
litellm 1.104.0
Automated static-analysis result. It can contain false positives and false negatives, and is not a claim about the intent of litellm's authors. Report a false positive.
Behavioral traits
How this component maps to the CSA agentic threat model. Descriptive — it never affects the risk score.
Findings (11)
The code turns strings into live code at runtime (eval / new Function / exec).
value = eval(source)
exec(compiled, exec_globals) # noqa: S102
exec(compiled, exec_globals) # noqa: S102
Why it matters: If those strings aren't fixed and trusted, they become a way to run arbitrary code.
Fix: Avoid evaluating dynamically constructed code; if unavoidable, ensure the input is a trusted constant and never derived from external data.
A hardcoded credential (API key, token, or private key) is shipped in the code.
"out of URLs and access logs. Example api_key='d534…[redacted, 64 chars]'"
"Example api_key='d534…[redacted, 64 chars]'"
Why it matters: Anyone who gets the package gets the secret — rotate it and load secrets at runtime instead.
Fix: Remove the secret from the code, rotate it immediately, and load credentials from the environment or a secrets manager at runtime.
The component can run operating-system commands or spawn processes.
subprocess.check_call([sys.executable, "-m", "pip", "install", "supabase"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "sentry_sdk"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "slack_bolt"])
return subprocess.run(command, env=dict(env), check=False).returncode
return subprocess.Popen(
[
sys.executable,
"-m",
"litellm.proxy.proxy_cli",
"--config",
str(config_path),
"--port", …result: Final = subprocess.run(("codex", "--version"), capture_output=True, text=True, timeout=5, check=False)output: Final = subprocess.run(
(binary, "--version"), capture_output=True, text=True, check=False, timeout=10
).stdoutprocess: Final = subprocess.Popen(self.argv)
result: Final = subprocess.run(resolve_prisma_argv(("prisma", "generate")), capture_output=True, text=True)process: Final = subprocess.Popen(
(
sys.executable,
"-m",
"litellm.proxy.prometheus_metrics_server",
"--host",
host,
"--port",
str(port), …subprocess.Popen(command, stdout=devnull, stderr=devnull)
subprocess.Popen(command, stdout=devnull, stderr=devnull)
Why it matters: Powerful and often legitimate — confirm the commands aren't built from untrusted input.
Fix: Confirm the command and its arguments are fully controlled and not derived from untrusted input; avoid shell=True.
A server is bound to all network interfaces (0.0.0.0), not just your own machine.
"0.0.0.0",
_IPV4_LOCAL_ADDRESS: Final = "0.0.0.0"
- if litellm.force_ipv4 is True, it will return AsyncHTTPTransport with local_address="0.0.0.0"
"local_addr": ("0.0.0.0", 0) if litellm.force_ipv4 else None,- If force_ipv4 is True, it will create an AsyncHTTPTransport with local_address set to "0.0.0.0"
``python -m litellm.proxy.prometheus_metrics_server --host 0.0.0.0 --port 4001``.
_WILDCARD_TO_LOOPBACK: Final = MappingProxyType({"0.0.0.0": "127.0.0.1", "::": "::1"})parser.add_argument("--host", default="0.0.0.0")@click.option("--host", default="0.0.0.0", help="Host for the server to listen on.", envvar="HOST")Why it matters: Without authentication, other hosts on the network can reach it.
Fix: Bind to 127.0.0.1 for local-only use, or require authentication and restrict access if remote exposure is intended.
The component reads files from disk.
with open(path, encoding="utf-8") as lines:
files("litellm").joinpath("anthropic_beta_headers_config.json").read_text(encoding="utf-8")with open("user_cost.json", "r") as json_file:with open(config_path) as f:
content: Final = file_path.read_text(encoding="utf-8")
content: Final = file_path.read_text(encoding="utf-8")
with open(json_path, "r") as f:
with open(file_path, "rb") as f:
with open(str(content), "rb") as f:
with open(str(file_content_obj), "rb") as f:
return open(file_path, "rb")
with open(str(file), "rb") as f:
raw: Final = Path(get_cli_token_file_path()).read_text()
content: Final = json.loads(files("litellm").joinpath("blog_posts.json").read_text(encoding="utf-8"))return files("litellm").joinpath("model_prices_and_context_window_backup.json").read_bytes()with open(file_content, "rb") as f:
return HuggingFaceTokenizer.from_str(Path(path).read_text(encoding="utf-8"))
with open(web_identity_token_file, "r") as f:
with open(str(file_content), "rb") as f:
with open(str(file_content), "rb") as f:
with open(image, "rb") as f:
with open(self.auth_file, "r") as f:
with open(config_path) as f:
return Path(image).read_bytes()
with open(self.access_token_file, "r") as f:
Why it matters: Usually legitimate, but worth confirming it can't be steered into reading sensitive files.
Fix: Confirm which files are read and that paths cannot be influenced by untrusted input to reach sensitive locations.
The component writes or deletes files on disk.
with open("user_cost.json", "w") as json_file:Path(path).write_text(self.to_str(pretty), encoding="utf-8")
with open(self.auth_file, "w") as f:
with open(self.access_token_file, "w") as f:
with open(self.api_key_file, "w") as f:
with open(local_path, "wb") as f:
os.unlink(local_requirements_path)
os.unlink(tmp_path)
os.unlink(tmp_path)
with open(cert_path, "w") as f:
with open(key_path, "w") as f:
os.unlink(tmp_file)
snapshot_file.write_text(json.dumps(result.fragments, indent=2, sort_keys=True) + "\n")
with open(log_path, "w") as log_file:
with open(resolved_path, "w") as f:
with open(filename, "w") as f:
path.write_text(report, encoding="utf-8")
path.write_text(SLASH_COMMAND_BODY, encoding="utf-8")
os.unlink(tmp_name)
with open(local_file_path, "w") as f:
with open(local_file_path, "w") as f:
with open(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), "w", encoding="utf-8") as handle:
shutil.copyfile(plan.ca_source, ca_path)
register_exit_hook(_only_in_this_process(lambda: shutil.rmtree(runtime_dir, ignore_errors=True)))
with open(path, "w", encoding="utf-8") as handle:
Why it matters: Usually legitimate, but worth confirming the paths can't be controlled by untrusted input.
Fix: Confirm which files are written/deleted and that paths cannot be influenced by untrusted input.
The component makes outbound network requests.
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,312130,e=>{"use strict";var t=e.i(843476),l=e.i(271645),a=e.i(519455),o=e.i(515288),s=e.i(793479),r=e.i(110204),n=e.i(571303),i= …`;t.document.write(a),t.document.close(),t.onload=()=>{t.print()}})(e),children:[(0,t.jsx)(G.FileText,{}),"Export as PDF"]}),(0,t.jsxs)(U.DropdownMenuItem,{onClick:()=>(e=>{let t=e.entries.filter(e=>null!==e.result),s=[["LLM Multi-Model Cos …}'`}),(0,t.jsx)("p",{className:"mb-2 mt-3 text-xs text-muted-foreground",children:"Look for these headers in the response:"}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children: …}`,em=({visible:e,initialJson:r,onSave:n,onClose:a})=>{let[l,o]=(0,s.useState)(r||ed),[i,c]=(0,s.useState)(null),d=()=>{c(null),a()};return(0,t.jsx)(q.Dialog,{open:e,onOpenChange:e=>!e&&d(),children:(0,t.jsxs)(q.DialogContent,{className:"ma …(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,180127,e=>{"use strict";let t=(0,e.i(475254).default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 1 …Why it matters: Usually legitimate, but confirm the destinations are expected and no sensitive data leaves.
Fix: Confirm the destination hosts are expected and that no sensitive data is sent off-host.
The component makes outbound network requests.
import httpx
import httpx
import httpx
self.response = response or httpx.Response(
status_code=self.status_code,
request=httpx.Request(method="POST", url="https://litellm.ai"),
)request=httpx.Request(method="POST", url="https://litellm.ai"),
import httpx
response: Final = httpx.get(url, timeout=timeout)
import httpx
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="delete_assistant", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="delete_assistant", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
response=httpx.Response(
status_code=400,
content="Unsupported provider",
request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
),request=httpx.Request(method="create_thread", url="https://github.com/BerriAI/litellm"),
Why it matters: Usually legitimate, but confirm the destinations are expected and no sensitive data leaves.
Fix: Confirm the destination hosts are expected and that no sensitive data is sent off-host.
An OAuth 2.0 / OpenID Connect delegated-authentication flow was detected (authorization-code / refresh-token / token-exchange grant, an OIDC authorize/discovery endpoint or id_token, or a delegation library). Tools authenticate with the end user's delegated, scoped credentials rather than a long-lived embedded service credential. (25 occurrence(s) shown as evidence).
id_token: Final = auth_data.get("id_token")derived: Final = self._extract_account_id(_optional_str(id_token or access_token))
"grant_type=authorization_code"
id_token: Final = _optional_str(data.get("id_token"))if not access_token or not refresh_token or not id_token:
"id_token": id_token,
"grant_type": "refresh_token",
id_token: Final = _optional_str(data.get("id_token"))if not access_token or not id_token:
"id_token": id_token,
id_token: Final = tokens.get("id_token")account_id: Final = self._extract_account_id(id_token or access_token)
"id_token": id_token,
XAI_OAUTH_DISCOVERY_URL: Final = f"{XAI_OAUTH_ISSUER}/.well-known/openid-configuration"id_token: ReadOnly[str | None]
id_token: NotRequired[ReadOnly[str | None]]
authorization_endpoint: NotRequired[ReadOnly[str]]
authorization_endpoint=discovery["authorization_endpoint"],
"grant_type": "authorization_code",
authorization_endpoint: Final = data.get("authorization_endpoint")if not authorization_endpoint or not token_endpoint:
"authorization_endpoint": self._validate_xai_endpoint(authorization_endpoint),
authorization_endpoint: str,
return f"{authorization_endpoint}?{urlencode(params)}""id_token": token_payload.get("id_token"),Fix: Delegated auth is a lower-blast-radius execution context than an embedded static credential. Confirm the requested scopes are minimal and that tokens are never logged or forwarded off-host.
A short-lived, scoped, assumed identity was detected — an STS AssumeRole / session token, a cloud managed or workload identity, an impersonated service account, a projected Kubernetes service-account token, or a dynamic-secret broker. Tools authenticate with a narrowly-scoped credential that expires, rather than a long-lived embedded service credential. (25 occurrence(s) shown as evidence).
DefaultAzureCredential,
ManagedIdentityCredential,
return ManagedIdentityCredential(client_id=_client_id)
return DefaultAzureCredential()
from azure.identity import DefaultAzureCredential
DefaultAzureCredential as AsyncDefaultAzureCredential,
credential=DefaultAzureCredential(),
"""Call STS AssumeRole and return temporary credentials."""
sts_response: Final = sts_client.assume_role(
6. From DefaultAzureCredential
# Try to get token provider from service principal or DefaultAzureCredential
"Using Azure AD token provider based on Service Principal with Secret workflow or DefaultAzureCredential for Azure Auth"
# try to get DefaultAzureCredential provider
Try to get DefaultAzureCredential provider
Token provider callable if DefaultAzureCredential is enabled and available, None otherwise
verbose_logger.debug("Attempting to use DefaultAzureCredential for Azure Auth")azure_credential=AzureCredentialType.DefaultAzureCredential,
verbose_logger.debug("Successfully obtained Azure AD token provider using DefaultAzureCredential")verbose_logger.debug("DefaultAzureCredential failed: %s", e)DefaultAzureCredential source) and the token is minted automatically
f"AZURE_CLIENT_SECRET / AZURE_TENANT_ID or any DefaultAzureCredential source) "
federated token, username/password, or `DefaultAzureCredential` / managed identity.
# ``_get_default_ttl_for_boto3_credentials`` (~59 minutes); AssumeRole STS credentials expire with
``_auth_with_env_vars`` (including when skipping AssumeRole because the runtime identity
non-refreshable ``Credentials`` cached ~59 min, inside the 3600s STS session), and AssumeRole
Fix: A scoped, short-lived identity is the smallest-blast-radius execution context. Confirm the assumed role / requested scope grants only the permissions the tool needs, and that the token lifetime is minimal.
An MCP tool surface (manifest or tool definitions) was found.
server.add_request_handler("tools/list", PaginatedRequestParams, handle_list_tools)server.add_request_handler("tools/call", CallToolRequestParams, mcp_server_tool_call)Why it matters: Just context — review which tools it offers and their permissions.
Fix: Review the declared MCP tools and their permissions.
How attackers abuse these capabilities
Interactive labs on the attack class behind the rules above. They show the technique, not anything found in litellm.
Check your own component
Run the same evidence-backed scan on any MCP server, agent skill, or package.
Scan your own componentHow we determine this: deterministic static analysis (regex + AST), evidence-anchored, no code execution. Methodology →