Skip to content

fix(plugins): hash loader cache keys so plugin config never leaks into diagnostics - #117237

Merged
steipete merged 1 commit into
mainfrom
fix/plugin-cachekey-hash
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/plugin-cachekey-hash

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Plugin-registry cache keys embed the full JSON-serialized normalized plugins config — including arbitrary per-plugin entries[<id>].config values — via buildCacheKey in src/plugins/loader-load-context.ts. That key is interpolated verbatim into PluginLoadReentryError ("plugin load reentry detected for cache key: …"), which lands in registry.plugins[].error and is therefore reachable from plugin status/diagnostics output. Anything an operator put in plugin config (tokens, URLs, internal names) could surface in diagnostics.

A partial redaction helper existed but only applied on the resolveRawConfigEnvVars path — every other load path serialized config into the key unredacted.

Why This Change Was Made

The key's only consumers compare it for equality (cache lookup, active-registry compatibility matching re-derives keys through the same builder). Nothing parses its structure. So the complete cache identity is now SHA-256 hashed: identical inputs produce identical keys, and no configuration bytes can appear in any key, error message, or status output. The now-redundant partial redaction helper is deleted rather than kept "just in case" — hashing supersedes it, and the raw-env path it guarded already had registry caching disabled.

User Impact

Plugin configuration values can no longer leak into error messages, logs, or openclaw plugins status output via loader cache keys. No behavior change to caching: hit/miss semantics are identical for identical inputs.

Evidence

  • node scripts/run-vitest.mjs src/plugins/loader.test.ts — 179/179 pass (verified independently by reviewer session); full loader family run by implementation session: 8 files, 221 tests.
  • New regression test: a sentinel config value (hunter2-sentinel) is asserted absent from the cache key, the reentry error message, and the plugin status error; the key is asserted to be a 64-char hex digest; the reentry assertion upgraded from substring to exact-message equality.
  • Structured autoreview (Codex, gpt-5.6-sol, high): clean, no actionable findings.
  • Prod diff is net -9 LOC (redaction helper deleted).

🤖 Generated with Claude Code

Runtime proof (added post-review)

Redacted terminal transcript triggering the real reentry path through the built dist loader, with a sentinel in plugin config: the emitted PluginLoadReentryError and registry.plugins[].error contain only the 64-char SHA-256 digest; the sentinel is absent from the error and from the entire serialized registry. Full transcript: #117237 (comment)

Live gateway on an integration build including this change: 3 plugins load in 1.0s, /readyz reports ready, clean 44ms shutdown — no caching behavior change.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 05:33
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 1:38 AM ET / 05:38 UTC.

ClawSweeper review

What this changes

The PR hashes plugin-loader cache identities so configuration values are no longer emitted in reentry errors or plugin status diagnostics.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

The proposed SHA-256 identity preserves equality-based cache matching while removing direct configuration text from the reentry diagnostic path. The patch appears correct, but this protected maintainer PR has only test-based evidence; keep it open for human review and a small redacted after-fix runtime proof.

Priority: P1
Reviewed head: 404e896f3f0993ec2fb9344af429675ae21b8fc3

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and regression coverage are solid, but test-only evidence does not meet the real-behavior proof gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports focused loader tests and CI, but includes no redacted after-fix runtime/status transcript; add terminal or log proof that the configured sentinel is absent from the emitted diagnostic. 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.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused loader tests and CI, but includes no redacted after-fix runtime/status transcript; add terminal or log proof that the configured sentinel is absent from the emitted diagnostic. 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 5 items Current leak mechanism: Current main serializes the full normalized plugin configuration into the textual cache key; only the raw-environment-resolution path replaces per-plugin config before that serialization.
Proposed cache contract: The PR retains construction of the complete cache identity and returns a SHA-256 hex digest. Inspected cache consumers treat the key as an opaque equality value for cache lookup or in-flight detection, rather than parsing it.
Regression coverage: The added fixture supplies a plugin-config sentinel, checks that the resolved key is a 64-character hex digest without the sentinel, and checks that the reentry and registry error values do not contain it.
Findings None None.
Security None None.

How this fits together

The plugin loader combines normalized configuration, discovery state, and activation options into a cache identity used to reuse registries and detect recursive loads. Registry failures are recorded on plugin entries and displayed by diagnostics and status callers.

flowchart LR
  A[Plugin configuration] --> B[Plugin loader]
  C[Discovery and install state] --> B
  B --> D[Cache identity]
  D --> E[Cache and reentry guard]
  E --> F[Plugin registry]
  F --> G[Status diagnostics]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused loader tests and CI, but includes no redacted after-fix runtime/status transcript; add terminal or log proof that the configured sentinel is absent from the emitted diagnostic. 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.
  • Resolve merge risk (P1) - The branch changes a security-sensitive diagnostic boundary but provides only focused test evidence in the body; a redacted after-fix runtime transcript should demonstrate the actual status/error output before merge.
  • Resolve merge risk (P1) - The maintainer label requires explicit human handling under repository policy even though the patch is small and source review found no correctness defect.
  • Complete next step (P2) - No mechanical patch repair is indicated; obtain real-behavior evidence and have a human review the protected security-sensitive diagnostic change.
Agent review details

Security

None.

PR surface

Source +8. Total +8 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 33 25 +8
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 33 25 +8

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: src/plugins/loader.base.test-utils.ts, serialized state: src/plugins/loader-load-context.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the full cache-identity inputs but expose only a deterministic SHA-256 digest, then attach a redacted real loader/status run showing a configured sentinel is absent from the emitted diagnostic.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the full cache-identity inputs but expose only a deterministic SHA-256 digest, then attach a redacted real loader/status run showing a configured sentinel is absent from the emitted diagnostic.

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

Yes. Source establishes a focused path: configure a plugin entry with a sentinel value, trigger same-key loader reentry, and inspect the registry error/status output; the PR adds that fixture, but this read-only review did not run it.

Is this the best way to solve the issue?

Yes. A deterministic digest preserves the existing equality contract while removing configuration bytes from all cache-key consumers, which is safer than retaining a path-specific partial-redaction helper.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The proposed repair addresses a concrete route by which operator-supplied plugin configuration can reach diagnostics, potentially exposing sensitive values.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add 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 reports focused loader tests and CI, but includes no redacted after-fix runtime/status transcript; add terminal or log proof that the configured sentinel is absent from the emitted diagnostic. 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.

Label justifications:

  • P1: The proposed repair addresses a concrete route by which operator-supplied plugin configuration can reach diagnostics, potentially exposing sensitive values.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • 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 reports focused loader tests and CI, but includes no redacted after-fix runtime/status transcript; add terminal or log proof that the configured sentinel is absent from the emitted diagnostic. 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

What I checked:

  • Current leak mechanism: Current main serializes the full normalized plugin configuration into the textual cache key; only the raw-environment-resolution path replaces per-plugin config before that serialization. (src/plugins/loader-load-context.ts:234, 0892684551fd)
  • Proposed cache contract: The PR retains construction of the complete cache identity and returns a SHA-256 hex digest. Inspected cache consumers treat the key as an opaque equality value for cache lookup or in-flight detection, rather than parsing it. (src/plugins/loader-load-context.ts:217, 404e896f3f09)
  • Regression coverage: The added fixture supplies a plugin-config sentinel, checks that the resolved key is a 64-character hex digest without the sentinel, and checks that the reentry and registry error values do not contain it. (src/plugins/loader.base.test-utils.ts:1407, 404e896f3f09)
  • History and ownership: Blame attributes the current textual cache-key construction to the current-main cache-identity commit by Peter Steinberger; the PR is a targeted follow-up by the same area contributor. (src/plugins/loader-load-context.ts:231, 0ae516da1fa3)
  • Current-main and release check: The target checkout is on current main, and the proposed commit is not contained in current main or any locally available release tag; this remains an open change rather than an implemented-on-main cleanup. (404e896f3f09)

Likely related people:

  • steipete: Current-main blame attributes the cache-key implementation to Peter Steinberger, and this PR is a focused follow-up on the same loader path. (role: current cache-identity author and recent area contributor; confidence: high; commits: 0ae516da1fa3, 404e896f3f09; files: src/plugins/loader-load-context.ts, src/plugins/loader-cache.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted terminal or runtime-log transcript that triggers the reentry path and shows the plugin status/error includes only the digest, never the configured sentinel.
  • After adding proof, update the PR body to trigger fresh review; if it does not, ask a maintainer to comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Runtime proof: reentry diagnostic emits digest only (redacted transcript)

Real-behavior proof per review: the built dist loader from this PR (dist/plugins/loader.js, branch merged into an integration build) was driven by a one-off script that installs a genuinely re-entrant plugin (its register() calls loadOpenClawPlugins again with identical options) with a sentinel value in its plugin config (entries["reentrant-proof"].config.token = "hunter2-proof-sentinel").

Terminal transcript (paths shortened):

[plugins] reentrant-proof failed during register from …/reentry-proof-GHyXiO/reentrant-proof/index.cjs: PluginLoadReentryError: plugin load reentry detected for cache key: cee2d8979449534f285b771e2626ad77267699861fc971ae9679a126084e55e5
plugin status : error
plugin error  : PluginLoadReentryError: plugin load reentry detected for cache key: cee2d8979449534f285b771e2626ad77267699861fc971ae9679a126084e55e5
digest in error       : yes (cee2d8979449…, 64 hex chars)
sentinel in error     : absent
sentinel anywhere in registry JSON: absent

The emitted diagnostic — the exact surface that previously interpolated serialized plugin config — now carries only the 64-char SHA-256 digest. The sentinel appears nowhere in the plugin record error nor anywhere in the full serialized registry.

Additional live-runtime evidence from the same integration build: ephemeral gateway (isolated state dir, loopback, port 39179) boots clean through the hashed-key loader — 3 plugins loaded in 1.0s, /readyz → {"ready":true,"failing":[]}, clean shutdown in 44ms.

🤖 Generated with Claude Code

@steipete
steipete merged commit 80b0e78 into main Aug 1, 2026
191 of 197 checks passed
@steipete
steipete deleted the fix/plugin-cachekey-hash branch August 1, 2026 05:46
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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.

1 participant