Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 3:56 PM ET / 19:56 UTC (Revision 3). ClawSweeper reviewWhat this changesThe secrets CLI preserves an existing entry’s protection mode during rotation, commits imports atomically, and adds regression coverage and documentation. Merge readiness⛔ Blocked before merge - 4 items remain This remains a useful fix for behavior still present on main. Both prior findings are addressed, including atomic import validation, and the refreshed runtime evidence supports the repair. No blocking code defect remains. Priority: P1 Review scores
Verification
How this fits togetherThe shared secret store holds protected credentials and agent-readable environment values in SQLite. CLI writes determine whether later listings and Gateway-hosted subprocesses receive plaintext or protected secret references. flowchart TD
A[CLI set or import] --> B[Read value and confirm]
B --> C[Store write transaction]
D[Current stored protection] --> C
C --> E{All entries valid?}
E -->|No| F[Reject without batch writes]
E -->|Yes| G[Commit values and protection]
G --> H[List output and agent environment]
Decision needed
Why: The source and runtime evidence support the repair, but repository policy reserves security-path involvement and material transaction acceptance for human owners. Before merge
Agent review detailsSecurityNone. PR surfaceSource +94, Tests +419, Docs 0. Total +513 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep stored protection authoritative during value rotation, preserve explicit operator overrides, and reject invalid imports without partial writes. Do we have a high-confidence way to reproduce the issue? Yes: current main still reclassifies an explicitly protected, non-suffix name during value-only rotation. Contributor process traces demonstrate the same mechanism; this read-only review did not execute it. Is this the best way to solve the issue? Yes: resolving protection inside the existing store transaction and validating the complete import batch is the appropriate owner-level repair; explicit operator overrides remain available. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fe565dd968a3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
e1f3ee8 to
13c7014
Compare
|
Rebased onto current main and pushed [P1] Revalidate inherited kinds inside the authoritative write - fixed, and thank you, the finding was correct. Security: concurrent protection changes can be overwritten - resolved by the same change, and proved as a final effect rather than by reading the source. Scenario B in the body starts a real Add real behavior proof, authority chain - the body now carries five traces across three trees: pristine main Merge risk: runtime evidence does not cover a protection change during pending input or confirmation - covered by scenario B above. The interleaving is real rather than simulated: two separate CLI processes against one SQLite store, with the protecting write confirmed committed before the pending value is released. Merge risk: incomplete broader CLI and store validation - re-run and clean on this head. Explicit permitted overrides - scenario C shows an operator-supplied Regression coverage: the two interleaving cases in Left to maintainers: the request for openclaw/openclaw-secops involvement is yours to route; I cannot add reviewers. One intended behavior change is also worth an explicit look, since it is a policy call rather than a bug fix: |
`secrets store set <NAME> --value-file <path>` resolved the entry kind from the name heuristic whenever no host-policy flag was passed, so rotating the value of an entry created with `--kind secret` under a name the heuristic does not classify as sensitive silently converted it into a readable `env` entry and deleted its `--allow-host` allowlist. `import` classified every entry from its name for the same reason. Both paths now inherit the stored kind, and that inheritance is resolved inside the authoritative store write transaction rather than captured before the CLI awaits its value or its confirmation. A protection change committed while one of those waits is pending is therefore no longer overwritten by the pending write, and the value it carries lands under the newer policy instead of reaching agent subprocesses as plaintext. Because a kind resolved at write time can invalidate a value the CLI already accepted, `import` now hands its whole batch to a single store-owned write. `writeSecretStoreEntries` resolves every live kind and validates every resulting entry inside one transaction before it writes any of them, so an entry that a concurrent protection change turns into an empty secret still fails the command with nothing committed, matching the existing no-write-on-validation-failure contract. An explicit `--kind` still overrides both the stored kind and the name heuristic in either direction.
13c7014 to
66a8c01
Compare
|
Rebased onto [P2] Validate and commit inherited import kinds as one batch ( Real-process evidence is in the body. With an existing env-kind Rank-up move, the regression you asked for. Merge risk (P1), argv value rotations of protected entries. Unchanged and still intended. Decision needed, secops sponsorship. Still open and still not author-actionable. I cannot add reviewers to this PR, so routing it to Reviewed head. The verdict above was written against Not run on this host: |
|
Closing this implementation PR at the author's request and moving the unresolved defect to #158968: #158968 The follow-up report records a fresh check on main The candidate at |
Summary
openclaw secrets store set <NAME> --value-file <path>silently converts a write-onlysecretentry into a readableenventry when only the value is rotated.The trigger is the ordinary credential-rotation path: an entry that was explicitly created with
--kind secretunder a name the automatic suffix heuristic does not classify as sensitive (OPENAI_KEY,ANTHROPIC_ADMIN_KEY,GH_PAT,AWS_ACCESS_KEY_ID), rotated with no--kindand no--allow-host/--clear-allowed-hosts.After the rotation the entry is no longer write-only.
openclaw secrets store listprints a preview of the rotated credential,openclaw secrets store getreturns it instead of refusing, every agent subprocess receives it as plaintext in its environment rather than a sealed sentinel, and the--allow-hostegress destination allowlist that bound the secret is deleted. Nothing warns the operator;setreportsStored OPENAI_KEY (env).and exits 0.openclaw secrets store importhas the same root cause and reclassifies every existing entry it rewrites.Root cause
src/cli/secrets-store-cli.tslooks the existing entry up only when a host-policy flag was passed, so the resolved kind falls back to the name heuristic on a plain value rotation:With no host flags
existingEntryisundefined, sostoreKind(undefined, name)appliesisSensitiveEnvName(src/secrets/secret-env-name.ts,/_?(API_KEY|TOKEN|PASSWORD|PRIVATE_KEY|SECRET)$/i).OPENAI_KEYdoes not match, so the operator's explicit--kind secretis replaced by"env".importnever looks an existing entry up at all.The upsert in
writeSecretStoreEntryInternalthen rewrites the stored kind and, forenv, nulls the host allowlist. Every consumer branches on the storedrow.kind, so one wrong resolution breaks four boundaries at once:readSecretStoreExecEnvironmenthandsenvrows to agent subprocesses as plaintext instead of sealing a sentinel and registering an egress binding,store getdrops its write-only refusal,renderListprintsvaluePreview, and the refusal of--valueon argv stops applying.The conditional lookup shows the intent was already to inherit the stored kind; it was scoped to the host-policy branch by accident.
Fix
Both CLI paths now inherit the stored kind, and that inheritance is resolved inside the authoritative store write transaction rather than captured in the CLI before it awaits input.
SecretStoreWriteParamsgains an optionalinheritExistingKind. When set, the store reads the live row inside the transaction it already opens, resolves the kind from that row, and drives value validation, the allowed-host refusal, and theallowed_hostsclearing from the resolved kind rather than the requested one:setandimportpassinheritExistingKind: options.kind === undefined, andwriteSecretStoreEntryreturns the kind it committed sosetreports what actually landed.This is correct because the name heuristic is a classifier for names that have never been seen before. Once an entry exists, its stored kind is a recorded operator choice and outranks a guess made from the name. An explicit
--kindstill wins over both, in either direction, so the operator keeps full control.Resolving at the write boundary rather than at the start of the command closes the replay window.
setawaitsreadSecretStoreInputandimportawaitsconfirmMutation, and both waits are human-scale. A kind captured before those waits could be replayed over a protection change committed during them, which would downgrade a freshly protected entry and delete the host allowlist the operator had just attached. Because the resolution now happens inside the same transaction as the insert, no store state can change between reading the kind and writing the row.Import writes its batch under one transaction
Resolving the kind at write time means a value the CLI already accepted can become invalid by the time it is written: an empty value is legal for an
enventry and refused for asecretone, so an entry that a concurrent protection change turns into a secret must fail.importpreviously wrote one entry per transaction, so that failure could arrive after earlier entries of the same batch had already committed, which breaks the no-write-on-validation-failure contract the existing empty-secret refusal insrc/cli/secrets-store-cli.test.tsrelies on.importnow hands its whole batch to the store as one call.writeSecretStoreEntriesresolves every live kind and validates every resulting entry before it writes any of them, inside the singlerunOpenClawStateWriteTransactionit already opened:writeSecretStoreEntryis now a single-entry call into the same code, so the two paths cannot drift, andwriteSecretStoreEntryWithRollbackkeeps its previous-value snapshot unchanged.Why this is the right boundary
The CLI is the only kind resolver in the codebase. The other writer of the store, the Gateway RPC
secrets.store.set, takeskindas a required field ofSecretsStoreSetParamsSchemaand passes it straight through, so it never infers a kind. It does not setinheritExistingKind, so its behavior is unchanged andwriteSecretStoreEntrystill receives a kind its caller decided.I considered instead refusing any
secret -> envtransition inside the store. That is wrong: an explicit--kind envdowngrade is a legitimate operator action, and the store cannot tell an explicit downgrade from an inferred one without being told.inheritExistingKindis exactly that missing signal, and it keeps the policy choice with the CLI while giving the store the atomicity only the store can provide. The same reasoning puts the batch in the store rather than in the CLI: only the store owns the transaction, and a CLI-side pre-check would just recreate the window it is meant to close.importis fixed in the same commit rather than left as a one-sided fix; it shares the root cause and reclassifies every existing entry it rewrites.docs/cli/secrets.mdstates that automatic detection applies to new names, that an existing entry keeps its kind, and that the inherited kind is resolved as the write commits.Verification
src/cli/secrets-store-cli.kind-inheritance.test.tsdrives the real commander program throughregisterSecretsCliagainst a real SQLite store in a temp directory. Eight cases pass: value-only rotation keeps a secret write-only and host-bound; an explicit--kind envstill downgrades; a brand-new name is still classified from its name;importkeeps an existing secret while classifying new names; a protection change made whilesetwaits for its value is applied; the same whileimportwaits for confirmation; a protection change that invalidates a later entry of an import batch leaves every entry of that batch unwritten; and an explicit--kindis still honored across that interleaving.expected { name: 'SERVICE_MODE', ... } to be undefined.src/secrets/store/secret-store.test.tspasses against the changed store, covering the existing empty-secret refusal, the allowed-host validation, the exec projection, and the hidden GitHub record paths.src/cli/secrets-store-cli.test.tspasses 15 of 15. Its import assertion now reads the single batch call instead of three separate writes, and its empty-secret refusal additionally asserts that the batch write was never reached.tsgoandoxlintwere not run on this host: this box cannot hold them without exhausting memory. Only the repository formatter and the two targeted suites above were run here, so a type error confined to new code would first surface in the repository's automated checks rather than locally.sk-protected-credential,sk-rotated-credential,plain-original-value,production-next).Real behavior proof
Behavior addressed: a value-only
openclaw secrets store setdowngraded a write-onlysecretentry to a readableenventry, handed the credential to agent subprocesses as plaintext, and deleted its--allow-hostegress allowlist. Inheriting the kind at write time then introduced a second failure, reported as the remaining review finding:openclaw secrets store importcould commit an earlier entry of its batch and then fail on a later one whose kind had just been changed by another process.Real environment tested: the real
openclaw secrets storecommand line entry point (src/entry.ts) run as separate processes against a real SQLite secret store in a scratchOPENCLAW_STATE_DIR, plus a real child process spawned from the environmentreadSecretStoreExecEnvironmentresolves, which is the same projectioncreateExecToolgives agent commands insrc/agents/bash-tools.exec-run.ts. The interfering process is a second realopenclaw secrets store setrun while the first command holds its confirmation prompt on a pseudo terminal. Captured on pristine maind23730ee7c54975df5f50294dca34a06592b3590, on the previous head of this PR13c7014552c3e43dd8f76a235c1aee6264e8c8d2, and on this head66a8c01c8db76bf63ab79c506880f462856b2d1e, with identical inputs and identical scripted timing. Only the credential values are synthetic.Exact steps or command run after this patch: scenario A creates
OPENAI_KEYwith--kind secret --allow-host api.openai.com, rotates it withopenclaw secrets store set OPENAI_KEY --value-file <rotated>, then spawns a real child from the resolved agent environment. Scenario B createsSERVICE_API_KEYas--kind env, startsopenclaw secrets store import --from values.envwherevalues.envholdsSERVICE_MODE=production-nextand an emptySERVICE_API_KEY=, leaves it waiting at its confirmation prompt for 12 seconds, protectsSERVICE_API_KEYfrom a second process with--kind secret --allow-host api.example.comduring that wait, answers the prompt, and then lists the store. Scenario C imports the same file with--yesand no interference. Each listing prints name, kind, allowed hosts and whether the value is withheld.Evidence after fix:
Observed result after fix: in scenario A the rotated entry stays
secreton this head instead of flipping toenv, keeps itsapi.openai.comegress binding instead of losing it, withholds the value from the listing, and hands the spawned child nothing rather thansk-rotated-credential. In scenario B all three runs exit 2 with the same message, but the store afterwards differs: pristine main and this head contain only the protectedSERVICE_API_KEY, while the previous head of this PR also containsSERVICE_MODE=production-next, a durable write from a command that failed. This head restores the all-or-nothing behavior pristine main had, now with the kind resolved from the live row. Scenario C shows the batch still writes every entry of an uninterfered import, so the repair did not trade partial writes for no writes.What was not tested: only the
teamscope was exercised, because it is the only scope the command line accepts today. The egress proxy was not driven end to end against a live upstream host, so the proof shows the restored binding and its allowed hosts rather than an intercepted outbound request. The Gateway RPC path was read but not driven, since it carries an explicit kind and does not request inheritance.