Skip to content

Prevent plaintext provider keys in generated models config - #84613

Closed
VibhorGautam wants to merge 2 commits into
openclaw:mainfrom
VibhorGautam:fix-models-config-plaintext-api-key
Closed

VibhorGautam wants to merge 2 commits into
openclaw:mainfrom
VibhorGautam:fix-models-config-plaintext-api-key

Conversation

@VibhorGautam

@VibhorGautam VibhorGautam commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Replace source-managed plaintext provider API keys with the existing non-secret marker before writing generated models config.
  • Add a regression test for runtime/source snapshot planning so resolved provider keys are not serialized into models.json.

Fixes #11829

Verification

FS_SAFE_PYTHON_MODE=auto FS_SAFE_PYTHON=/Library/Frameworks/Python.framework/Versions/3.14/bin/python3 \
  node scripts/run-vitest.mjs src/agents/models-config.runtime-source-snapshot.test.ts
  • oxfmt check: passed
  • git diff --check: passed
  • Tests: 12 passed

Real behavior proof

Behavior addressed: The models-config snapshot path serialized the source provider apiKey value (a resolved plaintext credential) directly into the generated models.json file.

Real environment tested: macOS 15.4.1, Node 22.15, local repo checkout at dc1f31b with FS_SAFE_PYTHON_MODE=auto and Python 3.14 (FS_SAFE_PYTHON).

Exact steps or command run after this patch:

FS_SAFE_PYTHON_MODE=auto \
  FS_SAFE_PYTHON=/Library/Frameworks/Python.framework/Versions/3.14/bin/python3 \
  node scripts/run-vitest.mjs \
  src/agents/models-config.runtime-source-snapshot.test.ts

Evidence after fix:

generated provider apiKey: secretref-managed
matches non-secret marker: true
contains plaintext source key: false
contains resolved runtime key: false

Observed result after fix: The snapshot planner substitutes secretref-managed for any resolved provider credential. All four values above are extracted live from the generated models.json structure during the local run. The three assertions that gate apiKey redaction fail without the patch; all twelve assertions pass with it.

What was not tested: Full integration run against a live cloud provider or production-configured deployment.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 5:42 AM ET / 09:42 UTC.

Summary
This PR changes source-managed provider planning to write the existing non-secret marker for plaintext source provider apiKey values and adds a regression test for generated model config.

PR surface: Source +6, Tests +34. Total +40 across 2 files.

Reproducibility: yes. at source level: current main returns no source marker for a non-SecretRef plaintext source apiKey, so the resolved runtime value can continue into generated providers. I did not run a mutating CLI reproduction in this read-only review.

Review metrics: 1 noteworthy metric.

  • Generated auth serialization rule: 1 changed apiKey marker rule. The PR changes how plaintext source provider credentials are serialized into generated model config, so upgrade and auth proof matter before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88562
Summary: This PR is a narrow candidate fix in the generated provider credential persistence cluster; the concrete open bug is canonical, while the broader security roadmap partially overlaps.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal or log proof from a real OpenClaw command that regenerates generated catalog files, shows plaintext keys are absent, and confirms provider auth still resolves.
  • Update the PR body with the proof so ClawSweeper can re-review automatically; if it does not, ask a maintainer to comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body only supplies Vitest/planner output; it still needs redacted terminal/log proof from a real OpenClaw command that regenerates generated catalog files and proves provider auth still resolves. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The supplied proof is still Vitest/planner output, not redacted output from a real OpenClaw command that regenerates generated catalog files and proves provider auth still resolves.
  • [P1] Replacing a generated plaintext apiKey with secretref-managed changes generated-config semantics for setups that treat generated models.json as standalone provider credential material.
  • [P1] This PR covers one source-managed plaintext path while the canonical generated-credential issue also discusses env marker/audit behavior, stale generated files, and generated plugin catalog sidecars.

Maintainer options:

  1. Require real generated-file auth proof (recommended)
    Ask for redacted terminal or log output from a real OpenClaw command that regenerates generated catalog files, shows plaintext keys are absent, and confirms provider auth still resolves after marker substitution.
  2. Accept the narrow source-path slice
    Maintainers can land this small source-managed marker change first, while keeping the canonical generated-credential issue open for sidecars, audit behavior, stale files, and migration coverage.
  3. Hold for canonical branch selection
    If maintainers want a single broader security branch, keep this PR as source material until a proof-positive replacement is cleanly mergeable or merged.

Next step before merge

  • [P1] Needs maintainer/security review to choose the canonical generated-credential branch and require contributor-supplied real OpenClaw proof; this is not a safe automated repair lane.

Security
Cleared: No supply-chain regression was found; the diff narrows credential serialization and adds no dependencies, workflows, package changes, or new code-execution surface.

Review details

Best possible solution:

Land one maintainer-selected generated-credential fix that removes prompt-visible provider secrets from root and plugin catalog outputs while preserving runtime provider auth and upgrade behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main returns no source marker for a non-SecretRef plaintext source apiKey, so the resolved runtime value can continue into generated providers. I did not run a mutating CLI reproduction in this read-only review.

Is this the best way to solve the issue?

Unclear as the final fix: the helper boundary is plausible for the plaintext source path, but the full generated-credential cluster still needs real generated-file/auth proof and maintainer branch selection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cf2efbe5d515.

Label changes

Label justifications:

  • P1: The PR targets provider credential exposure in prompt-visible generated model config, a high-priority security/auth workflow issue.
  • merge-risk: 🚨 compatibility: Generated models.json may stop carrying plaintext provider credentials for this source path, which can affect existing standalone generated-config usage.
  • merge-risk: 🚨 auth-provider: The diff changes provider auth material emitted into generated config, so provider auth resolution must be proven after redaction.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body only supplies Vitest/planner output; it still needs redacted terminal/log proof from a real OpenClaw command that regenerates generated catalog files and proves provider auth still resolves. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +6, Tests +34. Total +40 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 1 +6
Tests 1 34 0 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 41 1 +40

What I checked:

  • Repository policy applied: Root policy says provider routing, auth/session state, persisted preferences, generated config, setup/startup, and fallback behavior are compatibility-sensitive, and requires whole-surface PR review rather than diff-only review. (AGENTS.md:31, cf2efbe5d515)
  • Scoped agents guide checked: The scoped agents guide was read fully; it adds test-performance guidance for agent tests and did not override the auth/config review outcome. (src/agents/AGENTS.md:1, cf2efbe5d515)
  • Maintainer notes checked: Only .agents/maintainer-notes/telegram.md exists, so there were no matching maintainer notes for this agents/model-auth PR.
  • Current main still has the narrow gap: On current main, resolveSourceManagedApiKeyMarker returns undefined when the source provider apiKey is not a SecretRef, so a plaintext source-owned key does not force a non-secret generated marker. (src/agents/models-config.providers.source-managed.ts:47, cf2efbe5d515)
  • PR patch targets the source-managed helper: The PR imports isNonSecretApiKeyMarker and substitutes secretref-managed for non-marker plaintext source apiKey values in the same helper. (src/agents/models-config.providers.source-managed.ts:47, 6b39807e71e5)
  • Generated catalog serialization is broader than this helper: Current planning enforces source markers, then serializes root providers into models.json and plugin-owned providers into generated catalog sidecars, so the full credential issue is broader than the changed source path. (src/agents/models-config.plan.ts:273, cf2efbe5d515)

Likely related people:

  • steipete: GitHub commit history shows the source-managed helper was introduced in the split of model config source-managed helpers, which is the helper this PR changes. (role: feature-history owner; confidence: high; commits: 5c52824d3efe; files: src/agents/models-config.providers.source-managed.ts)
  • vincentkoc: Recent current-main history touches provider config helper exports and model-auth marker tests around the generated model config/auth marker boundary. (role: recent adjacent contributor; confidence: medium; commits: e93996378491, 64f9f3c278db; files: src/agents/models-config.plan.ts, src/agents/models-config.providers.secret-helpers.ts, src/agents/model-auth-markers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@clawsweeper

clawsweeper Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

@VibhorGautam thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@steipete

Copy link
Copy Markdown
Contributor

Thanks for the focused patch. We’re consolidating this security-sensitive generated-catalog work under #88562 and the maintainer-owned direction in #87166.

This branch handles only plaintext values present in the source-provider snapshot and represents them as secretref-managed, even though those values are not necessarily SecretRefs. It does not cover plaintext auth-profile resolution, current plugin catalog sidecars, stale generated files, or prove that request auth resolves the marker correctly.

Closing this narrower competing implementation so one current-main fix can define the marker/provenance contract and cover both generated outputs. #88562 and #11829 remain open for the underlying behavior. Thank you for the useful source-snapshot regression case.

@steipete steipete closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security Roadmap: Protecting API Keys from Agent Access

2 participants