Simon Willison released llm 0.37.2 on November 11, 2026 with fixes for two moderate GitHub security advisories that could send your real OpenAI API key to a third-party OpenAI-compatible server configured in extra-openai-models.yaml. Researcher Daniel de Araujo reported the issues to the simonw/llm project. Neither bug requires a malicious server operator to exploit you: a typo in api_key_name, a missing llm keys set, or a documented-safe -o chat_completions 1 flag is enough. If you run llm beside Claude Code, Codex, or automation that shells out to it, treat this as a credential-routing incident on the same tier as environment variable leaks and LLMjacking after key theft.
TL;DR
| Question | Answer |
|---|---|
| Am I affected? | Yes if pip show llm (or llm --version) is below 0.37.2 and you use custom api_base models in extra-openai-models.yaml |
| Is there a fix? | Upgrade to llm 0.37.2 (pip install -U llm) |
| What gets leaked? | Your OPENAI_API_KEY or the key stored as llm keys set openai, sent as Authorization: Bearer … to the third-party host |
| Does data leave my machine? | Yes, to whatever api_base URL you configured—without indicating OpenAI's key was used |
| Should I rotate keys? | Rotate OPENAI_API_KEY if you ran affected versions with custom endpoints; review OpenAI usage logs |
What llm uses extra-openai-models.yaml for
llm is Simon Willison's command-line tool for calling language models from scripts and terminals. Since the 0.6 release in July 2023, it has supported OpenAI-compatible providers through extra-openai-models.yaml (now manageable with llm openai endpoint add in 0.37). Each entry can set:
model_id— the name you pass tollm -mapi_base— a third-party URL such as a self-hosted gateway or another provider's compatibility endpointapi_key_name— which stored key llm should send to that hostresponses: true— use OpenAI's newer Responses API shape with optional delegation to Chat Completions
The project documentation presents api_key_name as the mechanism to avoid shipping your OpenAI key to non-OpenAI hosts. The November advisories show two paths where that expectation failed anyway.
Advisory 1: missing named key falls back to OPENAI_API_KEY (GHSA-v9h7-jj4g-f862)
GHSA-v9h7-jj4g-f862 is rated moderate (CWE-201: insertion of sensitive information into sent data). It affects every release from 0.6 through 0.37.1 for models that set both api_base and api_key_name.
Mechanism step by step
register_models()setsneeds_keyto the value ofapi_key_namebut leaves the model class's defaultkey_env_var = "OPENAI_API_KEY"in place.- When you run
llm -m <model_id>,get_key()resolves the alias first. - If no key is stored under that alias (typo, new laptop, forgotten
llm keys set thirdparty), resolution falls back to the environment variable, which usually holds your OpenAI key. - llm sends that value as
Authorization: Bearer …to the third-partyapi_base.
The advisory's reproduction is intentionally mundane:
- model_id: tp
model_name: m
api_base: "https://third-party.example/v1"
api_key_name: thirdparty # never stored with llm keys set
With export OPENAI_API_KEY=CANARY, llm -m tp 'hi' causes third-party.example to receive Bearer CANARY. The same happens from Python via llm.get_model("tp").get_key().
Historical note on even broader leakage
Between 0.6 and 0.7.1, the advisory notes OPENAI_API_KEY took precedence over stored keys, so it could be sent even when the named key existed (issue #158, fixed in 0.8). The November fix addresses the remaining case: env fallback when the named key is missing.
What 0.37.2 changes
The suggested fix in the advisory sets key_env_var = None on chat and async models when api_base is set, so missing aliases raise No key found - add one using 'llm keys set …' instead of silently using OpenAI's key. That is a behavior change: anyone who deliberately put a third-party key in OPENAI_API_KEY for an api_base model must move it to llm keys set <name>.
Why this stayed open so long
The interaction between api_key_name and OPENAI_API_KEY is not a new debate inside the project. Issue #158 in 2023 documented cases where the environment variable overrode a named key on early releases. That regression was fixed in 0.8, but the advisory's missing-key fallback remained the common case for anyone who skimmed the docs, added a gateway URL, and forgot the matching llm keys set step. Because the HTTP request still succeeds (the third party happily accepts a valid OpenAI key), operators assumed routing worked as documented. Only someone reading Authorization headers on the foreign host—or OpenAI's usage dashboard—would notice.
From a threat-modeling angle this is misdelivery, not malware: you pointed traffic at Server B and accidentally mailed Server B your Server A password. That is still a credential disclosure under CWE-201, and it is the same class of mistake agents amplify when they generate config files faster than humans audit them.
Advisory 2: chat_completions delegate on responses models (GHSA-r639-rr7r-x72w)
GHSA-r639-rr7r-x72w is also moderate. It affects 0.32a2 through 0.37.1 when a custom model sets api_base and responses: true but does not set api_key_name—the configuration the docs describe as safe because the OpenAI key should not be sent by default.
Mechanism step by step
- For
api_basemodels,register_models()sets the outer Responses model'sneeds_key = None, so the Responses path does not attach an OpenAI key (correct). - When you pass
-o chat_completions 1, Responses builds a delegate Chat model using_delegate_chat_kwargs(). - That kwargs dict does not include
needs_key, andneeds_keyis not a constructor argument, so the delegate keeps the class defaultneeds_key = "openai". - The outer model passes
key=None.Chat.get_client()callsget_key(None), which returnsOPENAI_API_KEYor the storedopenaikey. - The third-party
api_basereceives Bearer <your OpenAI key> even though documentation says it will not.
Reproduction from the advisory:
export OPENAI_API_KEY=CANARY
llm -m tp 'hi' # Responses path: dummy key (correct)
llm -m tp -o chat_completions 1 'hi' # Chat delegate: CANARY (leak)
If api_key_name is set and that key is stored, the outer model resolves the right key and passes it through—no leak. The bug is specific to the documented-safe case with no api_key_name.
What 0.37.2 changes
The fix copies self.needs_key onto the delegate inside Responses.execute() and AsyncResponses.execute() after constructing the Chat delegate. The advisory explains why this was not a one-line constructor change: needs_key is not a Chat.__init__ argument, and third-party plugins import Chat directly—so the patch assigns the attribute post-construction, matching how register_models() already configured the parent Responses object.
When you might hit the chat_completions path
The Responses API shape is newer than classic chat completions. Operators enable responses: true when a provider exposes OpenAI's Responses surface but still needs Chat Completions for some options. Forcing -o chat_completions 1 is an explicit compatibility switch—exactly the sort of flag you try once when debugging a gateway integration. The advisory's grid of twelve combinations (Chat vs Responses vs Responses+chat_completions, with and without api_key_name, env vs stored keys) failed only the two delegate cases, which is why both reports shipped together in 0.37.2 rather than as isolated one-line patches.
Who reported it and how it was found
Both advisories credit Daniel de Araujo as reporter. He states he found the issues during an AI-assisted documentation review, reproduced them, and tested patches locally. BluePlexus is credited on the second advisory. Simon Willison's release note links both GHSAs and notes llm openai endpoint add as the newer way to manage endpoints introduced in 0.37.
What this means if you run AI coding agents
Coding agents rarely ship llm as their core runtime, but developers often install llm for quick terminal tests, for OpenRouter or local gateway experiments, or because an agent-generated script calls it. That overlap matters:
- Agents share your shell environment. If
OPENAI_API_KEYis exported for Codex or Claude Code, llm inherits the same variable. A misconfiguredextra-openai-models.yamlcan exfiltrate that key to a third party the next time a script runsllm -m proxy …. - CI and MCP gateways. Teams that point agents at LiteLLM or self-hosted compatibility layers sometimes mirror the same YAML patterns llm uses. The bug is llm-specific, but the lesson generalizes: never assume "custom base URL" implies a separate key without verifying the client's resolver logic. See Railway's October incident for how fast stolen keys move once they leave the intended route.
- No UI warning. The advisories emphasize users get no indication the OpenAI key was substituted. Detection is provider-side (unexpected usage on OpenAI's dashboard) or server-side (third-party logs showing OpenAI-formatted keys—something you may not control).
Checks and fixes
llm --version
pip show llm | grep ^Version
pip install -U 'llm>=0.37.2'
Open or locate your config (typically extra-openai-models.yaml under llm's config directory—see llm keys documentation for the path on your OS). For every entry with api_base:
- Run
llm keys set <api_key_name>for eachapi_key_nameyou rely on. - Remove stale entries you no longer use (agents love appending config files).
- Avoid
-o chat_completions 1on responses models until you are on 0.37.2 or have set an explicitapi_key_name.
Rotate OPENAI_API_KEY at platform.openai.com if you used custom endpoints on affected versions. Scan agent job logs for historical llm -m invocations if your harness archives shell commands.
If you maintain a shared developer image or Nix/Devcontainer recipe that installs llm for every engineer, pin llm==0.37.2 in the same place you pin nodejs, uv, or claude-code. Supply-chain scanners that only watch npm will miss PyPI CLI tools until you add an explicit inventory.
Review API keys in logs and env vars and Ghost Campus-style FOFA harvesting for the broader pattern: keys in the environment are the default prize.
What Beam can and cannot do here
Beam watches Claude Code and Codex tool proposals through PreToolUse hooks, scans skills and MCP configs with heuristic patterns, and redacts known secret formats before events are stored locally. It does not sit in the HTTP path between llm and a third-party api_base, so it cannot block the Authorization header these bugs sent. If an agent runs llm as a shell command, Beam may record the invocation in your local event log (with redaction on captured output), which helps after-the-fact review, not prevention. Treat version pinning and separate keys per endpoint as the fix; use Beam to catch agents that read .env or curl unexpected hosts once you wire workspace policy on supported harnesses.
How this fits next to other key-routing incidents
| Incident | What leaked | Beam angle |
|---|---|---|
| llm 0.37.2 GHSAs (Nov 2026) | OpenAI key to custom api_base | Pin llm; separate keys; rotate |
| LiteLLM compromise | Gateway credentials via supply chain | Scan MCP/uv launches |
| Mandiant LLMjacking | Stolen cloud keys resold | Billing alerts; least privilege |
Frequently asked questions
Which llm versions are affected by the OpenAI key leak?
GHSA-v9h7-jj4g-f862 affects llm 0.6 through 0.37.1 for models with api_base and api_key_name when the named key is not stored. GHSA-r639-rr7r-x72w affects 0.32a2 through 0.37.1 when you run a responses model with -o chat_completions 1 and no api_key_name. Both are fixed in 0.37.2.
What is the fixed version of llm?
0.37.2, published November 11, 2026. Simon Willison's release note and both GitHub advisories list 0.37.2 as the patched release on PyPI.
How do I check my llm version?
Run llm --version. With pip, run pip show llm and read Version. Upgrade with pip install -U llm or your package manager's equivalent.
Could I have leaked a key without noticing?
The advisories say nothing in the UI indicates the OpenAI key was used instead of a third-party key. Check OpenAI usage logs for unfamiliar activity, rotate OPENAI_API_KEY if you used custom api_base models on affected versions, and store third-party keys with llm keys set.
Does this affect Claude Code or Codex directly?
Not as built-in clients. It affects anyone who runs Simon Willison's llm CLI on the same machine as coding agents, including scripts agents invoke or CI jobs that proxy models through OpenAI-compatible gateways.
Did Beam or LiteLLM have the same bug?
These advisories are specific to simonw/llm. Gateway products such as LiteLLM have had separate credential issues; treat each tool's advisory on its own terms and pin versions per project.
Related reading
- API keys in logs and env vars
- Mandiant on LLMjacking and stolen LLM access
- NIK C2 and OPENAI_API_KEY fallback on Windows
- Operation Ghost Campus and exposed agent keys
- LiteLLM 1.107.0 PyPI compromise
- Beam landing: what we watch locally
Advisory severities, affected version ranges, and patch details reflect GitHub and Simon Willison's posts as of November 11, 2026. PyPI metadata and llm configuration paths can change—verify before production use.

