Skip to content

fix(update): identify unsafe recovery objects in failure reports - #164858

Merged
steipete merged 1 commit into
mainfrom
upd/package-swap-unsafe-object-report
Oct 4, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/package-swap-unsafe-object-report

Conversation

@steipete

@steipete steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Closes #164188
Supersedes #164395 (same patch; that branch's GitHub diff metadata drifted after merges from main, so the security review could not run). Original diagnostic contribution by @xydigitLybnnnn, credited as co-author.

What Problem This Solves

Fixes: package updates reject unsafe recovery objects without telling operators which object failed or what metadata was observed.

User Impact

Recovery refusals now retain the object role and basename, octal mode, link count, owner UID, and expected private permissions in update failure facts and public reports. Installation paths and file contents stay out of this diagnostic. Ownership, object-type, permission, and hard-link protections remain unchanged. The diagnostic requires an updated installed updater; a candidate cannot add it to a 2026.9.7 or 2026.9.8 updater already running.

Why This Change Was Made

Both published drivers contain the same retention inventory and recovery guard. Their retention path can hard-link a prior control directory's operation.sqlite, so a private 0600 journal becomes multiply linked regardless of umask. Main already excludes recovery controls from runtime retention in #160663. This PR completes the missing diagnostic: the recovery owner supplies the object role, and report redaction preserves the bounded metadata instead of treating the generated basename as a hostname.

Directories retain their existing exemption from the file link-count rule. Helper and journal creation already use private modes; the shipped helper's archive mode is not copied to the updater-created helper. The separate publication-identity variant already has an ownership/path diagnostic on main via #164797. The original reports did not preserve enough metadata to establish that every host rejected the same object.

Thanks to @xydigitLybnnnn for the original diagnostic contribution, and to @creanet-64, @jrpasolini, @jb168, and @burchk007-jpg for the reports and filesystem observations.

Evidence

  • Three real-journal regressions fail before the change and pass afterward: linked journal, group-readable journal, and group-accessible control directory. They verify failure facts and the public report while preserving the rejected evidence.

  • Changed suites passed three times on Blacksmith Testbox: 25 journal tests and 52 redaction tests each run. Combined wrapper wall times: 37.47 s, 35.17 s, 34.75 s. Journal file wall times: 34.40 s, 32.54 s, 32.13 s, with approximately 19 s of test time; the new three cases together take about 0.13 s. Redaction file wall times: 1.29 s, 0.719 s, 0.738 s.

  • All 38 directly importing or one-barrel importing files were selected: 680 tests passed in 158.34 s; 13 existing skips cover Linux-root-only launcher and macOS-only ownership cases. Longest executed test: 18.1 s.

  • Independent Codex P1 autoreview: scoped-clean, no actionable findings.

  • Published-driver reproduction on Blacksmith Testbox tbx_01m43396zp91rn1mk6fh2w5rb6 (lease workflow): official 2026.9.7 driver → official 2026.9.8 candidate, user-owned npm prefix, native-volume storage, umask 077, pre-existing completed receipt, isolated state and a free loopback port. Both tarballs matched their registry SHA-512 integrity. A read-only lstatSync tracer recorded the rejected inode. The driver failed at package-swap after required candidate admission/validation succeeded (advisory Doctor lint remained deferred), and verified serving 2026.9.7 healthy afterward.

before: operation.sqlite inode=5553120 mode=0600 nlink=1 uid=1001
during: operation.sqlite inode=5553120 mode=0600 nlink=2 uid=1001
package-swap: Package publication recovery permissions are unsafe
recovery: version=2026.9.7 service=healthy serviceRunning=true readyz=true

The cell used scripts/e2e/lib/upgrade-survivor/published-driver.mjs with temporary fixture preparation and observation code. To create a valid prior receipt, it backed up the disposable installed build-info.json, ran the published 9.7 updater against the exact 9.7 tarball with restart disabled, and asserted that the original published build identity was restored before starting the managed Gateway and the 9.7 → 9.8 attempt. The receipt-seeding update took 132.606 s; the reproduced update took 67.227 s. These are real installed-update operations, separate from unit-test timings. The published driver's guards and executable payload were not patched. An initial same-version seed correctly returned a no-op and was discarded as fixture-only evidence.

The 9.7 and 9.8 tags have identical recovery-guard and retention-inventory blobs, so 9.8 is affected too. Main's retention fix prevents a corrected installed driver from creating this alias; it cannot replace the older driver already executing an update. The recorded production reports cannot retrospectively identify every original host's object. After-fix reporting is proven at the real journal-to-failure-report boundary; this evidence does not claim an after-fix installed-CLI run or native macOS/arm64 execution.

Source delta against the tested main base: production +52/-26, tests +93/-0, docs +7/-0 (8 files). Auto-merge remains off.

node scripts/check-changed.mjs --base bced15851945c3c460b48c03896701f9fa304536 passed on Blacksmith Testbox tbx_01m4322j69qnmtgr1rzehpe2zz (lease workflow), including all 27 test typecheck graphs, changed-file lint, dead exports, and import-cycle checks. The combined remote command exited 0 in 28m24.6s; a subsequent runner-portal synchronization warning did not change the command result. This is task-owned Testbox evidence, not a claim that hosted PR CI has finished.

The current retention owner also passed three focused runs using a temporary variation of its existing real-filesystem fixture: package at npm/lib/node_modules/openclaw, sibling activation control directory, openclaw peer dependency discovering the outer module owner, and umask 077. Both cases passed each run: normal retention leaves operation.sqlite single-linked and absent from the projection; an explicit runtime dependency link to that recovery state is refused. Runtime assets remain available. The temporary fixture variation was restored after the proof and is not a product change.

The contributor commit 9a5962ee495c7bfd63723b93a3cc17c86110723a remains in the branch ancestry. Its direct guard tests are replaced by the existing POSIX journal suite’s real-object/report cases, addressing the Windows-scoping and public-report findings. No auto-merge or merge is requested.

Replacement for #164395 on a clean branch (its GitHub diff metadata had
drifted to 6,788 files after merges from main, so the security review
could not evaluate it). Same patch as its head 8cf3087.

Closes #164188

Co-authored-by: xydigitLybnnnn <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 4, 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.

@steipete
steipete marked this pull request as ready for review October 4, 2026 10:01
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 4ed7ec119d3277c5df400e93bc11c6d74cad5171
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/logging/diagnostic-support-redaction.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 6:06 AM ET / 10:06 UTC.

ClawSweeper review

What this changes

The PR makes package-update failure reports identify rejected recovery objects and their filesystem metadata while omitting installation paths and contents.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and v2026.9.8 still discard recovery-permission metadata. No actionable introduced defect was found, and the maintainer-owned replacement preserves the existing safeguards.

Priority: P2
Reviewed head: 4ed7ec119d3277c5df400e93bc11c6d74cad5171

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused diagnostic repair with meaningful boundary regressions and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified maintainer authority exempts this PR from the external-contributor proof gate. Supplied after-fix coverage exercises real journal objects through failure facts and report preparation; the published-driver trace establishes the original refusal and healthy recovery, not an after-fix installed-CLI run. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified maintainer authority exempts this PR from the external-contributor proof gate. Supplied after-fix coverage exercises real journal objects through failure facts and report preparation; the published-driver trace establishes the original refusal and healthy recovery, not an after-fix installed-CLI run. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduction reviewed: The exact introduced delta changes recovery diagnostics, their internal callers, public redaction, regression coverage, and documentation. Directory exemptions and rejection predicates remain unchanged.
Current main still needs the diagnostic: Comparison with fetched main confirms that its recovery guard still throws the generic permission refusal and lacks this bounded recovery-report exception. This endpoint comparison establishes current behavior, not PR ownership.
Latest release retains the generic refusal: The v2026.9.8 source has the same permission/link-count predicate and constant error without object metadata.
Findings None None.
Security None None.

How this fits together

The package updater checks recovery files before opening journals or publishing an installation. Rejection diagnostics flow through update failure facts and redaction into operator-visible reports.

flowchart TD
  A[Package update] --> B[Recovery objects]
  B --> C[Identity and permission checks]
  C --> D[Accepted recovery operation]
  C --> E[Bounded rejection metadata]
  E --> F[Failure facts and redaction]
  F --> G[Operator failure report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +26, Tests +93, Docs +7. Total +126 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 52 26 +26
Tests 2 93 0 +93
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 152 26 +126

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #164188
Summary: This PR owns the diagnostic repair for the open canonical issue; the prior submission is closed unmerged.

Members:

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

Technical review

Best possible solution:

Keep recovery safety checks intact and carry compact object metadata through the existing diagnostic and public-report owners.

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

Yes: current main rejects a valid owned file with multiple links or group permission bits using a constant message that omits available metadata. This was source-inspected; no local runtime reproduction was executed.

Is this the best way to solve the issue?

Yes: enriching the existing guard and preserving its bounded diagnostic through report redaction fixes the proven defect without changing recovery policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 96c7ddc7e798.

Labels

Label changes:

  • add P2: This repairs a bounded diagnostic defect while existing refusal and recovery behavior remain intact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified maintainer authority exempts this PR from the external-contributor proof gate. Supplied after-fix coverage exercises real journal objects through failure facts and report preparation; the published-driver trace establishes the original refusal and healthy recovery, not an after-fix installed-CLI run. No stored-data contract changes.

Label justifications:

  • P2: This repairs a bounded diagnostic defect while existing refusal and recovery behavior remain intact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified maintainer authority exempts this PR from the external-contributor proof gate. Supplied after-fix coverage exercises real journal objects through failure facts and report preparation; the published-driver trace establishes the original refusal and healthy recovery, not an after-fix installed-CLI run. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction reviewed: The exact introduced delta changes recovery diagnostics, their internal callers, public redaction, regression coverage, and documentation. Directory exemptions and rejection predicates remain unchanged. (src/infra/package-update-activation-paths.ts:88, 4ed7ec119d32)
  • Current main still needs the diagnostic: Comparison with fetched main confirms that its recovery guard still throws the generic permission refusal and lacks this bounded recovery-report exception. This endpoint comparison establishes current behavior, not PR ownership. (src/infra/package-update-activation-paths.ts:88, 96c7ddc7e798)
  • Latest release retains the generic refusal: The v2026.9.8 source has the same permission/link-count predicate and constant error without object metadata. (src/infra/package-update-activation-paths.ts:40, fc23bc864e45)
  • Report boundary and negative controls: Three added cases create real journal/control objects, introduce links or unsafe modes, and inspect failure facts and prepared public reports while checking evidence preservation. Redaction cases reject appended private prose, absolute paths, and unknown roles. These tests were inspected, not executed. (src/infra/package-update-activation-journal.test.ts:317, 4ed7ec119d32)
  • Security scope: The new public exception runs after existing secret/path sanitization and accepts a complete bounded metadata grammar. All guard callers preserve their previous file/directory classifications; no authorization, schema, dependency, or execution-permission change is introduced. (src/logging/diagnostic-support-redaction.ts:443, 4ed7ec119d32)
  • Discussion and supplied validation: The captured PR body credits the original contribution, records repeated focused and importer-suite passes, and supplies a published-driver trace showing operation.sqlite becoming multiply linked while the old Gateway recovered healthy. It explicitly distinguishes that before-fix installed run from after-fix journal/report regression coverage. Related issue comments include Linux, arm64, and macOS observations plus successful manual installation. (4ed7ec119d32)

Likely related people:

  • Peter Steinberger: Raw commit f0af328 adds src/infra/package-update-activation-paths.ts:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f0af328d2475; files: src/infra/package-update-activation-paths.ts)

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 merged commit 4d2617d into main Oct 4, 2026
191 of 194 checks passed
@steipete
steipete deleted the upd/package-swap-unsafe-object-report branch October 4, 2026 10:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: package-swap permission failure does not identify rejected recovery object

1 participant