Skip to content

fix: strip apiKey from models.json to prevent secret leakage (Layer 1, #11829) - #83754

Closed
jing11223344 wants to merge 1 commit into
openclaw:mainfrom
jing11223344:fix/strip-apikey-models-json
Closed

jing11223344 wants to merge 1 commit into
openclaw:mainfrom
jing11223344:fix/strip-apikey-models-json

Conversation

@jing11223344

Copy link
Copy Markdown

Description

Layer 1 quick fix for #11829: strip apiKey from each provider before serializing to models.json to prevent secret leakage into prompt context.

Problem

The model catalog serializes resolved apiKey values into models.json, which gets included in prompt context. This can leak LLM provider keys to the agent.

Fix

Before writing models.json, each provider's apiKey field is stripped via object destructuring. The rest of the provider config (endpoint, model list, parameters) is preserved.

Changes

src/agents/models-config.plan.ts: Added sanitization step in planOpenClawModelsJsonWithDeps() between secret resolution and JSON serialization.

Verification

  • Existing provider resolution pipeline unchanged
  • Only the serialization output is sanitized
  • Runtime auth still works (apiKey is resolved at call time, not from models.json)

@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 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: the useful Layer 1 problem is now tracked by a canonical issue, while this branch is conflicting, lacks real behavior proof, removes marker-backed auth too broadly, and only targets the old root models.json serialization path.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88562
Summary: This PR is an unsafe candidate for the generated catalog provider-secret problem now tracked by the canonical issue.

Members:

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

Canonical path: #88562 is open and specifically tracks generated models.json apiKey serialization plus plugin catalog sidecar leakage.

So I’m closing this here and keeping the remaining discussion on #88562.

Review details

Best possible solution:

Keep the canonical generated-catalog secret issue open and land one marker-aware, security-reviewed fix that covers root models.json, plugin catalog sidecars, runtime auth, and audit behavior.

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

Yes for the patch defect: source inspection shows the PR deletes every provider apiKey, while current main recognizes non-secret apiKey markers and requires apiKey for generated provider rows with models unless auth explicitly allows missing keys. I did not run mutating tests because this review is read-only.

Is this the best way to solve the issue?

No. The patch is root-only against an older planner shape and removes marker-backed auth metadata indiscriminately; the safer path is the canonical issue's marker-aware root/plugin catalog fix.

Security review:

Security review needs attention: The diff touches credential persistence and needs attention because it removes auth markers indiscriminately, misses current plugin catalog sidecars, and uses an unassigned CVE placeholder.

  • [high] Marker-backed auth can be stripped — src/agents/models-config.plan.ts:178
    The patch removes every serialized provider apiKey, including non-secret markers that current runtime/auth code treats as meaningful.
    Confidence: 0.91
  • [medium] Root-only hardening misses sidecars — src/agents/models-config.plan.ts:83
    Current main writes plugin-owned generated catalogs separately from root models.json, so a replacement security fix must cover both generated output paths.
    Confidence: 0.86
  • [low] Unassigned CVE placeholder — src/agents/models-config.plan.ts:178
    The source comment names a placeholder CVE without evidence of an assigned advisory, which can confuse security tracking.
    Confidence: 0.86

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • Vincent Koc: Current blame and git log for the planner split and marker helper point to recent current-main work on this surface. (role: recent current-main area contributor; confidence: medium; commits: d0812126c845, 844f405ac1be, 74e7b8d47b18; files: src/agents/models-config.plan.ts, src/agents/model-auth-markers.ts)
  • steipete: Related live PR metadata shows a maintainer-labeled branch for the same Layer 1 problem, and git history shows repeated models-config planning refactors. (role: adjacent replacement-branch author and model-config refactor contributor; confidence: high; commits: 53f6d962c25f, 9e8151f34720, c29b09874416; files: src/agents/models-config.plan.ts, src/agents/model-auth-markers.ts, src/agents/models-config.applies-config-env-vars.test.ts)
  • Josh Avant: Git history shows earlier SecretRef-safe models.json persistence and source-managed marker work directly adjacent to this auth/catalog contract. (role: SecretRef and model-secret hardening contributor; confidence: high; commits: 8e20dd22d890, 36d2ae2a2235, 0bcb95e8fa5e; files: src/agents/model-auth-markers.ts, src/agents/models-config.providers.source-managed.ts, src/agents/models-config.plan.ts)

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

@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 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 20, 2026
@clawsweeper

clawsweeper Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. 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. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant