Skip to content

fix(secrets): avoid false plaintext findings for config-owned env markers - #184328

Open
wyf027 wants to merge 3 commits into
openclaw:mainfrom
wyf027:fix/secrets-owned-env-markers-121543
Open

wyf027 wants to merge 3 commits into
openclaw:mainfrom
wyf027:fix/secrets-owned-env-markers-121543

Conversation

@wyf027

@wyf027 wyf027 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Generated models.json intentionally stores an env SecretRef variable name as its API-key marker. openclaw secrets audit --check --json incorrectly reports a custom marker such as FACTCHAT_API_KEY as plaintext even when the same configured provider owns that exact reference.

Fixes #121543. Related to #87723.

User Impact

Source-owned custom env markers no longer produce misleading plaintext warnings. Other providers, sensitive headers, losing aliases, and literal credentials retain their findings.

Why This Change Was Made

The audit reuses the writer’s normalizeSourceProviderLookup and resolveConfigSecretRef(..., includeResolved: true). It first selects the canonical source provider, then exempts only that provider’s API key when its exact value equals the owning env-reference ID. This preserves provenance through populated shorthand and $include resolution without adding another parser or changing serialization.

Credit to @cho2559 for the report, @SebTardif (#121578), @wangmiao0668000666 (#121594), @LiuwqGit (#121633), and @Alix-007 (#87873) for earlier work. All four earlier PRs are closed without merging; #121578’s closing discussion invites a fresh repair. This implementation addresses the populated-include, canonical-winner, and import-cycle concerns in those discussions. Merged #97622 covers known markers on the config audit surface and does not resolve this custom-provider case. The issue comments and related PR discussions were read in full; no active replacement was found.

Evidence

  • Regression before/after: applying the new tests to production base b703c84a84c947e198b6a683408a3ddaba9179c4 gives 2 failed / 28 passed. Only the owned populated-include marker and canonical winning env marker fail. The PR passes 30/30 audit tests; cross-provider, header, losing-alias, and literal-winner controls remain covered.
  • node scripts/run-vitest.mjs src/secrets/audit.test.ts src/agents/models-config.runtime-source-snapshot.test.ts src/agents/models-config.merge.test.ts --maxWorkers=1: 46 tests passed across 3 files, 189.1 s total including isolated worker preparation. The infra project took 107.7 s and the writer merge project 16.7 s. The four new audit cases took 7.6 s; they use the existing real config/SQLite audit fixture rather than a second mocked loader.
  • Built production CLI evidence: pnpm --silent openclaw secrets audit --check --json on an isolated populated $include fixture goes from base exit 1 / plaintextCount 1 to PR exit 0 / plaintextCount 0. Running the built node openclaw.mjs secrets audit --check --json with a losing alias and an unrelated provider still exits 1 and reports exactly those two paths (providers.openai.apiKey, providers.unrelated.apiKey). Both runs use the real config loader and audit command; the on-disk generated catalog is a synthetic fixture. The repository runtime build completed successfully.
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo: passed. The test shard node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-tools.json --incremental also passed.
  • node --import ./scripts/tsx.mjs scripts/check-import-cycles.ts: passed. Format, focused lint, git diff --check, and the test-line ratchet passed. The prepared parent comparison uses --no-merge-base because this isolated checkout is shallow. The unique allocation grants exactly the 46 net new regression lines, without changing a baseline scalar.
  • Initial independent Codex autoreview --mode local --base b703c84a84c947e198b6a683408a3ddaba9179c4 --max-priority P3: scoped-clean, no actionable findings in the selected patch and supplied provenance/provider-owner context. Its report explicitly states that unchanged audit and loader context was unavailable; it did not execute tests. A supplemental run attempted to supply the complete audit and snapshot owners, but the helper refused --dataset src/secrets/audit.ts as a sensitive path before starting a reviewer. That guard was not bypassed. No complete-context local review is claimed. The historical hosted review of head 49bcc58fafbed6919682fc1d1cf6ed702cace91a inspected the audit, canonical provider, loader provenance and original security intent, accepted the CLI evidence, and recorded no findings / ready for maintainer review. Its durable review comment was marked stale after integration, then refreshed on November 2, 2026 at 03:03 UTC for current head 612d5e981b45d6f01b5490fdd536fe0498c222d4. That current-head review reports no actionable findings, accepts the supplied production CLI proof, and remains blocked only on an authorized maintainer's required security-sensitive-change approval. It does not replace that approval; the older 49bcc58fafbed6919682fc1d1cf6ed702cace91a verdict remains historical evidence. All 116 checks observed on historical head 49bcc58fafbed6919682fc1d1cf6ed702cace91a were complete without failure before marking Ready. The simplification pass retained the existing owners and the one-file +18/-0 production change.

Validation uses Node 24.22.1, repository-pinned dependencies, isolated config/state, and synthetic values. No real provider request, external tenant, Windows-specific behavior, or full repository test-suite result is claimed. AI-assisted implementation, regression work, and independent review.

Prior-head CI limitation

The typecheck job for that prior head failed with TS2353 in test/scripts/full-release-validation-at-sha.candidate.test.ts:335: releaseRef is absent from the fixture options. Its synthetic merge 8dfa309e used main be0d5c97b500a5762145a9b0ca4b073450ef6b37. Both failing test and fixture are byte-identical on that main and merge (Git blobs 91fe9bfb50b720cf691cf5a0187547b05dd379b2 / 5dbec4d665cdd81a3d5c690bb188614165234d3e). Running the same root-scripts graph on unmodified main adb3500df87603a849f1a965c6fc23ce269c25db with OPENCLAW_LOCAL_CHECK=0 node scripts/run-tsgo-core-test-shards.mjs --root-stripe 2/4 reproduces the identical diagnostic (exit 2, 14.5s). This is inherited CI failure evidence; no check, fixture, or approval policy is bypassed. Other test checks on that recorded head completed without failures.

Upstream baseline synchronization

Merged pinned upstream main 50c3ff63fcd42100dbf0bd0ff677c759ffee3178 into this existing branch to include #187339, merged at 230619948b35fedb88bf5dbc528c7fd3f2fb07df. That accepted upstream change removes the unsupported releaseRef fixture option and makes the existing branch/tag resume cases select their intended CLI ref; no check rule or product behavior was weakened.

The prior check-test-types-core-3 failure was the same test-root-scripts TS2353 reproduced on old main. The upstream PR's exact root scripts graph passed in 11.3 seconds; #184319's later run of the same graph also passed in 14.3 seconds after taking the corrected upstream base. The local canonical --root-stripe 2/4 command additionally passed at main 9a3bf9584db0d1f6be90e46d0224d228118fc3b6 (3.15 seconds wall), with the affected fixture and graph-owner bytes unchanged.

This is a real two-parent merge of original head 49bcc58fafbed6919682fc1d1cf6ed702cace91a and pinned main, previewed with Git's three-way merge and the verified historical merge base b703c84a84c947e198b6a683408a3ddaba9179c4. All PR-owned file blobs are unchanged by this merge. The earlier product tests/runtime captures above remain evidence for those original owner bytes and their recorded base; they are not presented as tests of this entire new merged candidate. No additional local tests or builds were run for this synchronization. New-head hosted CI/review is pending.

Hosted CI after upstream synchronization (2026-10-29T07:53:58.459Z)

Current head 612d5e981b45d6f01b5490fdd536fe0498c222d4 passed check-test-types-core-3, so the former releaseRef TS2353 failure is cleared on this exact published head. The required openclaw/ci-gate completed successfully. The independent security-maintainer approval is still required for this current SHA; this CI result is not that approval. No new product changes or local tests/builds were made for this status check. Prior runtime proof retains its recorded source scope, and existing hosted source-review comments are not relabeled as new-head reviews.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Accept generated API-key markers only when the matching canonical provider configuration owns the exact environment reference.

Example: A custom provider references ${FACTCHAT_API_KEY}, and its generated models.json stores FACTCHAT_API_KEY.

  • Before: The audit reports PLAINTEXT_FOUND and exits 1.
  • After: The owned marker is accepted; unrelated providers and sensitive headers remain findings.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused ownership repair with shipped CLI proof, meaningful regression controls, and no actionable findings; existing stored formats are unchanged.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied Node 24 production CLI output exercises the real loader and audit command with isolated synthetic configuration: the owned populated-include marker becomes clean, while losing-alias and cross-provider markers retain findings; the relevant production and regression blobs are unchanged on the current head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators receive plaintext warnings for intentionally generated custom environment-reference markers.
Reason: The change restores agreement between the documented writer contract and audit output while preserving real credential findings.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a current audit false positive with a focused change and no actionable code findings; current-head maintainer security approval remains required.

Priority: P2
Reviewed head: 612d5e981b45d6f01b5490fdd536fe0498c222d4

Before merge

  • Await maintainer action - An authorized maintainer must review head 612d5e9 and provide the required security-sensitive-change approval before merge.

Findings

None.

Agent review details

How this fits together

The secrets audit reads configuration provenance and generated model catalogs, classifies credential residues, and returns findings and CLI exit status.

flowchart TD
  A[Provider configuration] --> B[Config loader and provenance]
  A --> C[Model catalog writer]
  C --> D[Generated model catalog]
  B --> E[Secrets audit]
  D --> E
  E --> F[Findings and exit status]
Loading

Technical review

Best possible solution:

Preserve the catalog format and use existing provider ownership and loader provenance to classify exact env markers.

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

Current-main source establishes the false-positive path, and supplied CLI before/after results demonstrate it through secrets audit; no target code was executed during this review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: it reuses canonical provider selection and recorded reference provenance without introducing a parser, state store, serialization change, or global marker heuristic.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 416f43f345c5.

Provenance checked

  • Generated catalog credential classification keeps the original intent (8e20dd2: Detect persisted credentials while avoiding broad uppercase-name exemptions that could conceal real secrets.)
  • Canonical provider ownership keeps the original intent (60040d8: Use one collision contract so exact canonical provider spelling wins and source-managed credentials remain attached to the correct provider.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +18, Tests +46, Other +2. Total +66 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 18 0 +18
Tests 1 46 0 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 66 0 +66

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #121543
Summary: This PR addresses the canonical custom-marker audit failure and incorporates lessons from earlier unmerged repairs.

Members:

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Label justifications:

  • P2: Custom-provider references produce misleading audit failures while model requests remain functional.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-26T07:25:46.003Z sha f9595a9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-29T04:53:57.068Z sha 49bcc58 :: needs maintainer review before merge. :: none

Reviewed November 1, 2026, 10:03 PM ET / November 2, 2026, 03:03 UTC (Revision 3).

wyf027 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Head 49bcc58 adds complete runSecretsAudit regressions for populated include ownership and canonical/losing aliases. Base: 2 expected failures / 28 passes; candidate plus writer suites: 46 passes. The built production CLI now gives exit 0 / plaintextCount 0 for the owned include marker; losing-alias and cross-provider controls still give exit 1 with exactly two findings. Type, import-cycle, lint, formatting and ratchet checks passed.

The body records the initial local review's missing unchanged-owner context and the supplemental helper's sensitive-path refusal before reviewer startup; that guard was not bypassed and no complete-context local review is claimed. This remains Draft while the hosted review reassesses the source and actual CLI evidence.

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@wyf027
wyf027 marked this pull request as ready for review October 29, 2026 04:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T05:05:11.365903Z
We couldn’t complete this review. Comment @codex review to try again.
49bcc58 Draft marked ready
ℹ️ 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" or "@codex security review".

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

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: 612d5e981b45d6f01b5490fdd536fe0498c222d4

These sensitive security changes were made:

  • src/secrets/audit.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 31, 2026

wyf027 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review current head 612d5e981b45d6f01b5490fdd536fe0498c222d4. The earlier request for 49bcc58fafbed6919682fc1d1cf6ed702cace91a completed on October 29. All three PR-owned blobs, including the audit owner used by the recorded CLI proof, are unchanged after the upstream integration; current-head product CI passed. The body now labels the old hosted verdict as historical. The local review still lacks complete audit/loader context because its supplemental sensitive-path request was refused before startup; that guard was not bypassed. Independent security-maintainer approval is still outstanding.

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-review-required security-sensitive-changed size: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: models.json regenerates with unresolved SecretRef as bare literal string instead of ${VAR}/object

1 participant