Repository navigation
Avoid writing plaintext profile keys to models.json - #83296
jackspiece wants to merge 1 commit into
Conversation
|
Codex review: found issues before merge. Reviewed July 1, 2026, 2:22 AM ET / 06:22 UTC. Summary PR surface: Source +46, Tests +208. Total +254 across 4 files. Reproducibility: yes. from current source inspection: current main can still fill a model-bearing provider apiKey from a plaintext auth profile, and the current planner only writes model-bearing providers when an apiKey remains. I did not run tests because this cleanup review is read-only. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land one rebased canonical Layer 1 fix that keeps plaintext secrets out of prompt-visible model catalogs while preserving provider rows, env/SecretRef markers, plugin catalog splitting, and explicit upgrade behavior for existing keys. Do we have a high-confidence way to reproduce the issue? Yes, from current source inspection: current main can still fill a model-bearing provider apiKey from a plaintext auth profile, and the current planner only writes model-bearing providers when an apiKey remains. I did not run tests because this cleanup review is read-only. Is this the best way to solve the issue? No, not as-is against current main. The safer fix is to keep plaintext out of models.json while preserving a prompt-safe marker or adding an explicit, tested change to the writable-provider contract and upgrade policy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0c7bac34ae68. Label changesLabel justifications:
Evidence reviewedPR surface: Source +46, Tests +208. Total +254 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
a5338a9 to
7f79418
Compare
|
Thanks, addressed the merge-mode finding. The updated patch re-normalizes after merge-mode preservation so existing values matching plaintext auth-profile keys are stripped, while unrelated user-managed provider keys stay intact. Added a regression test through planOpenClawModelsJsonWithDeps for that exact path. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
7f79418 to
80de67d
Compare
|
Thanks, addressed the no-model-row gap from the latest review. The strip path now resolves the plaintext auth profile whenever the provider already has an apiKey, even if models is empty. I added a merge-mode regression for an existing OpenAI provider with models: [] and a matching plaintext profile key, while preserving an unrelated custom provider key. Checks run locally:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Thanks for the careful follow-ups and regression coverage. We’re consolidating this security-sensitive behavior under #88562 and the maintainer-owned direction in #87166. Current main now filters model-bearing providers on Closing this older competing implementation so the marker, runtime-auth, migration, and both-output contract can be solved once against current main. The underlying bug remains open; concrete new evidence should go to #88562. Thank you for the useful tests and proof. |
Summary
This keeps plaintext auth-profile API keys out of generated
models.json.The provider normalization path already preserves env and SecretRef-backed credentials as markers. Plaintext auth-profile keys could still be copied into the generated provider config when a provider had models but no configured
apiKey, when a generated providerapiKeymatched the plaintext profile key, or when merge mode preserved an existingmodels.jsonvalue after the first normalization pass.This PR skips plaintext profile keys for
models.jsonpersistence, strips matching plaintext values during provider normalization, and re-normalizes after merge mode preserves existing provider fields. The strip also applies to merge-preserved provider entries with no model rows, so old plaintext profile keys do not survive just becausemodelsis empty. Unrelated user-managed provider keys stay intact.Real behavior proof
Behavior or issue addressed: plaintext auth-profile API keys should not be persisted into generated
models.jsonprovider entries, including merge-mode regeneration from an existingmodels.jsonand merge-preserved provider entries withmodels: [].Real environment tested: local OpenClaw checkout on Android/arm64 Termux with Node v24.13.0. I used a temp agent directory with a real
auth-profiles.jsonentry containing a plaintextopenai:defaultkey. The merge-mode proof used an existing parsedmodels.jsonwith an OpenAI provider whoseapiKeymatched that plaintext profile key,models: [], plus a separate custom provider with an unrelated user-managed key.Exact steps or command run after this patch: ran a
node --import tsx --input-type=modulescript that saved the plaintext auth profile, calledplanOpenClawModelsJsonWithDepsinmodels.mode = \"merge\", parsed the generated contents, and printed whether the merged OpenAI provider still had anapiKeyproperty and whether the unrelated custom provider key was preserved.Evidence after fix: terminal output from the proof command:
{ "action": "write", "openaiModelsLength": 0, "openaiHasApiKeyProperty": false, "openaiApiKeyValue": null, "customApiKeyPreserved": true, "providerIds": [ "openai", "custom" ] }Observed result after fix: merge mode keeps the OpenAI and custom provider entries, removes the OpenAI
apiKeyvalue that matched the plaintext auth profile even though the OpenAI provider has no models, and preserves the unrelated custom providerapiKey.What was not tested: full native
tsgoin this environment, because@typescript/native-preview-android-arm64is unavailable. Plaintscon the full core test project also ran out of heap locally.Tests
node_modules/.bin/vitest run --config test/vitest/vitest.agents.config.ts src/agents/models-config.providers.normalize-keys.test.tsnode_modules/.bin/vitest run --config test/vitest/vitest.agents.config.ts src/agents/models-config.applies-config-env-vars.test.ts src/agents/models-config.merge.test.tsnode_modules/.bin/oxlint src/agents/models-config.plan.ts src/agents/models-config.providers.normalize.ts src/agents/models-config.providers.secret-helpers.ts src/agents/models-config.providers.normalize-keys.test.tsgit diff --checkAddresses #11829