Repository navigation
Stop unsloth start codex and openclaw from inheriting provider API keys - #10316
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
GitHub Actions A/B reproductionPinned head: Two branches staged onto fresh upstream Without the fix — failing run (main only):
The launched argv is unchanged in both cases ( With the fix — passing run (main + this head): The same probe also passed on the previous head ReviewNo blocking findings in the changed code. One gap was worth closing: Full |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Confirmed that in unsloth_cli/commands/start.py only the claude command passes unset_env, so codex and openclaw still inherit OPENAI_API_KEY and the Codex tokens from the shell, and the no-launch recipe never unsets them. Will get this reviewed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a99bcd5d54
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| command, | ||
| launch = launch, | ||
| install_hint = install_hint, | ||
| unset_env = _OPENCLAW_ENV_UNSET, |
There was a problem hiding this comment.
Mask the OpenAI key instead of removing it
When OpenClaw is launched natively from a project containing OPENAI_API_KEY in .env, this does not prevent the credential leak: _launch implements unset_env by deleting the variable from child_env, after which OpenClaw's documented environment loading reads the current directory's .env without overriding variables that are already defined. The key is therefore restored and can still select remote OpenAI embeddings for memory search. Pass an explicit empty OPENAI_API_KEY for the OpenClaw process (as the generated one-line recipe already does), or explicitly disable/configure remote memory search.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
OpenClaw does not read OPENAI_API_KEY from a project .env, so there is nothing to mask here. loadDotEnv() loads <cwd>/.env through loadWorkspaceDotEnvFile, which drops every entry rejected by shouldBlockWorkspaceDotEnvKey, and OPENAI_API_KEY is in BLOCKED_PROVIDER_AUTH_WORKSPACE_DOTENV_KEYS (openclaw/openclaw src/infra/dotenv.ts, in place since #54631 and #57767). The global runtime dotenv cannot restore it either: the command sets OPENCLAW_STATE_DIR to the session dir, so loadGlobalRuntimeDotEnvFiles reads <session>/.env and skips ~/.config/openclaw/gateway.env.
The one path that does refill a deleted key is the login-shell import, and it only runs when the user sets OPENCLAW_LOAD_SHELL_ENV=1 or enables env.shellEnv in their own config, which the session config here replaces. Asking OpenClaw to import your login shell is an explicit opt-in, so it stays the user's call.
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Pushed one follow-up to the branch, 648422a. The openclaw list was missing Verified against the real client (openclaw 2026.9.2) driven by the child environment this command builds, using the session config Also checked the boundary so the list stays minimal:
|
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…hell OPENCLAW_LOAD_SHELL_ENV makes OpenClaw run a login shell and import any provider key it cannot see. The keys dropped for the launch are exactly the ones it looks for, so on a machine with that switch set the session got them straight back out of the user's profile and the strip did nothing. Verified against openclaw 2026.9.2: with the switch on, loadShellEnvFallback applied CODEX_API_KEY and OPENAI_API_KEY to the child environment this command builds. Setting the switch to 0 in the child reports skippedReason disabled and applies neither. OPENCLAW_STATE_DIR stays a real path on purpose, since OpenClaw falls back to the user's home when it is blank.
|
Merged latest main into the branch and pushed one follow-up, Merge conflictOne conflict, in The strip was being undone on the openclaw side
So on a machine with that switch set in the shell, the session got both keys straight back out of the user's profile, and the launch strip did nothing. The WSL path was already immune, since the bridge blanks rather than deletes. Driven against the real client (openclaw 2026.9.2, its own
Four new tests cover it, parametrized over Rest of the reviewNo other blocking findings.
One thing this cannot reach, for a separate issueOpenClaw imports Codex CLI credentials from Full |
OpenClaw ORs env.shellEnv.enabled with OPENCLAW_LOAD_SHELL_ENV, so a persisted true wins over the environment guard and the login shell import runs anyway. write_openclaw_config preserves the top-level env section, so a --persist or reused config carried that opt-in into the session and handed the provider keys back after the launch dropped them. Verified against openclaw 2026.9.2 with a config holding env.shellEnv.enabled true: the fallback applied CODEX_API_KEY and OPENAI_API_KEY before this, and reports skippedReason disabled after.
|
@codex security review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Only the claude command strips provider keys from the launched agent's environment. codex and openclaw inherit the user's OPENAI_API_KEY and Codex tokens from the shell. The codex constant for this already existed but was only used by the subagent bridge, never by the command itself.
For openclaw this matters more than it looks. OpenClaw turns memory search on by default and uses OpenAI for it, so a user with OPENAI_API_KEY in their shell gets their memory quietly sent to OpenAI from a command that is meant to keep everything local.
Both commands now drop these keys, and the printed no-launch recipe unsets them too. The codex subagent parent is left alone since that is the user's own cloud Codex and needs its keys.
Tests cover both commands and the recipe. They fail on main and pass here.