Repository navigation
fix(cli): refuse another agent's credentials after restore - #145692
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, 2:55 AM ET / 06:55 UTC (Revision 3). ClawSweeper reviewWhat this changesLocal inference commands now check that an agent database belongs to the selected agent before preparing saved credentials, including when a secrets snapshot is already active. Merge readiness⛔ Blocked before merge - 3 items remain This remains a useful, focused repair absent from fetched main. No introduced correctness defect was found; the retained proof covers legitimate credentials and foreign-owner refusal. The recorded owner-review approval needs reconciliation with the restricted-path ownership requirement. Priority: P2 Review scores
Verification
How this fits togetherLocal inference commands select an agent and prepare its saved credentials before calling an embedding or media provider. The auth database adapter checks the database’s recorded owner through the shared state ownership assertion. flowchart TD
A[Local inference command] --> B[Selected agent and directory]
B --> C[Read database ownership]
C --> D{Owner matches?}
D -->|No| E[Refuse before provider request]
D -->|Yes| F[Prepare or reuse secrets]
F --> G[Provider request and output]
Decision needed
Why: The approval comment is relevant, but its author’s listed-owner authority is not established in the available evidence; code correctness and runtime proof cannot establish that authority. Before merge
Agent review detailsSecurityNone. PR surfaceSource +25, Tests +5. Total +30 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the existing durable-owner assertion consistently across local inference, with security-owner acceptance of the refusal and preservation of legitimate fresh and upgraded account behavior. Do we have a high-confidence way to reproduce the issue? Yes: restore an agent backup, register its directory under another agent ID, and invoke local embedding inference. Fetched-main source lacks the identity check, and the supplied CLI observations demonstrate the failure; this read-only review did not execute it. Is this the best way to solve the issue? Yes: passing the selected identity to the existing database-owner assertion is a narrow repair, and checking before snapshot reuse closes the demonstrated bypass without adding a competing policy or schema. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 354943cc2f7e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
landpr-approve-admin-merge |
2e81eb5 to
f1a33f0
Compare
|
landpr-approve-admin-merge |
|
Landed the saved-credential ownership repair, found by the adversarial round as a follow-up to #144931.
|
…145692) Related: openclaw#144931 ## What Problem This Solves Restoring an agent backup and registering that directory under a new agent name lets local capability inference use the original agent's saved credential. This follows supported `backup create`, `backup restore --target`, and `agents add --agent-dir` commands. Local model inference already refuses the durable owner mismatch. Follow-up to our openclaw#144931; found by the adversarial round, with no external reporter. ## Why This Change Was Made The shared local account preparation now passes the selected identity to the auth database owner before resolving credentials, including when a secrets snapshot is active. The auth reader delegates to the existing durable schema-owner assertion without requiring a newer session schema. No schema, migration, configuration, or protocol change. The decision 'may this agent use this saved credential' is made by exactly one mechanism at `src/state/openclaw-agent-db-schema-helpers.ts:311`. ## User Impact A restored directory registered under another name now produces the same owner-mismatch refusal across local inference commands before any provider request. Legitimate saved credentials continue to work. ## Evidence Pinned base: `79a02b57732d6f4b24c7325d41a452d9d494e319`. - Supported restore reproduction: base embedding exits 0 and sends one recorded provider request with the original agent's synthetic credential. The model control exits 1 with `belongs to agent ops; requested agent restored` and sends no request. - Candidate `2e81eb5998b460c47463907b0b8fdac88b19ead0`: restored embedding and model both exit 1 with the owner mismatch and zero provider requests. All six repaired commands—embedding, image generation, image description, audio transcription, video generation, and video description—reject the foreign owner before dispatch. Model inference remains a separate unchanged control. A supplemental video-generation capture uses the configured recorder endpoint: the legitimate owner creates and downloads a video; the restored owner exits 1 with the owner mismatch and sends zero create/content requests. - Final pre-landing rebase: head `f1a33f00c1c7cdcc332b3e5464430f46a49e044c` preserves the exact repair patch and all four changed files. The six restored-owner refusal commands and legitimate-owner video/model controls were refreshed on this head; prior pinned-base, rotation, older-state, and targeted-test evidence remains retained. - Legitimate saved-reference accounts succeed for all six command families. The known multi-agent image-description forwarding failure remains unchanged; the sole-agent description control succeeds, as in the original proof. openclaw#145188/openclaw#145171 track that separate path. - Rotated credentials succeed through model, embedding, image edit, describe-many, audio, video generation/download, and video description. An unavailable unrelated credential does not block the healthy account. - Previous state: v2026.9.4 application source created a schema-19 saved account; candidate embedding succeeds with its credential through the existing schema-20 upgrade path. The older source needed only upstream build-tool repair openclaw#144831 to complete its build; application sources were unchanged from the tag. - All six registered capability regression cases fail on the original code. Candidate capability tests: 255 passed; auth SQLite sibling: 16 passed. The helper provenance test passes after an isolation-only correction. - A source-blind validator independently ran the supported restore and legitimate-account CLI flows on pre-rebase head `2e81eb5998b460c47463907b0b8fdac88b19ead0`: PASS. The focused post-rebase CLI refresh was run by the repair worker. - Proof uses synthetic credentials and a loopback provider to measure actual credential routing and request absence. ## Consumers Seven calls to `prepareLocalCapabilityAccountSecrets` cover local `model run`, `embedding create`, image `generate`/`edit`, image `describe`/`describe-many`, audio `transcribe`, video `generate`/download, and video `describe`. Their shared preparation retains the selected identity and validates before credential use. No command-specific predicates were added. `capability` is an alias for the same registered command tree at `src/cli/capability-cli.ts:106-124`, as documented by `docs/cli/infer.md:9`; it reaches the same preparation owner. Test consumers: `src/cli/capability-cli/local-account-secrets.test.ts:35,49` imports and calls the preparation helper for source-config provenance, and lines 18-20 mock the new auth-owner adapter for isolation. `src/cli/capability-cli.test.ts:336-338` mocks shared preparation for command-wiring coverage. `assertAuthProfileStoreAgentOwner` has one production caller: shared local capability account preparation. The existing canonical assertion remains used by agent database schema, read-only access, writable open, admission, and maintenance. Model preparation also reaches that same assertion through persisted model-catalog reads. Memory CLI uses its separate config-reference preparation in `extensions/memory-core/src/cli-runtime-common.ts`; adversarial finding F4 remains separate. Provider listings, web, and speech synthesis do not consume this helper. Related open PRs openclaw#145188 and openclaw#145171 forward agent identity through media-understanding calls. They are separate from this saved-credential admission. Preserve the shared preparation call when reconciling landing order. Their branches and metadata were not changed. ## Invalidation No owner verdict is cached. Every shared preparation call reads durable metadata, before the active-snapshot shortcut. Existing auth read-pool lifecycle and credential revision invalidation remain the owners. Credential mutation advances the revision; snapshot activation validates it; clearing the runtime clears linked snapshots. Database/root closure and process exit close pooled readers. No additional cache or lifecycle was introduced. ## Contention No explicit transaction, lock, or queue is held across an await. The short metadata read uses the existing auth read connection and busy policy. Credential preparation retains its existing asynchronous lifecycle. ## Tests The registered entry points `infer image generate`, `infer image describe`, `infer embedding create`, `infer audio transcribe`, `infer video generate`, and `infer video describe` each first succeed for their durable owner, then reject another selected identity without further credential egress, with both active and cleared secrets snapshots. Deletion ledger: removed the helper-only “does not replace an already active secrets runtime snapshot” case because its no-directory-resolution assertion preserved the unsafe bypass. The registered-command cases now cover admission with an active snapshot. The helper source-config provenance case remains, with its new database dependency mocked to keep fixed paths isolated. Moved side effects: none. Production grows by 25 net lines to connect explicit selected identity to the existing durable decision through the version-tolerant auth reader. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #144931, #145188, #145171, #144831.
What Problem This Solves
Restoring an agent backup under a different agent name could let local capability commands use the original agent's saved credential. Local model inference already rejected this ownership mismatch.
Why This Change Was Made
Shared local account preparation now passes the selected agent identity to the existing durable credential-owner check before resolving credentials, including when a secrets snapshot is active.
User Impact
Local inference rejects credentials owned by another agent before making a request. Legitimate accounts continue to work. No schema, migration, configuration, or protocol change is required.
Consumers: embedding, image generation and description, audio transcription, and video generation and description now enforce the same saved-credential ownership rule.
Evidence
Supported backup restore and agent registration commands reproduced credential use before the fix. All six repaired command families then rejected the restored identity with zero recorded requests. Legitimate and rotated credentials succeeded against a recording endpoint. Registered capability regressions failed before the fix; 255 capability tests and 16 auth database tests passed. Post-rebase command checks passed. Previous-release saved accounts remained usable. A separate multi-agent image-description forwarding issue remains tracked by #145188 and #145171.