Skip to content

fix: prevent session exports from writing outside workspace - #104708

Merged
steipete merged 2 commits into
openclaw:mainfrom
VACInc:fix/2026.7.1-export-session-boundaries
Jul 14, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
VACInc:fix/2026.7.1-export-session-boundaries

Conversation

@VACInc

@VACInc VACInc commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Closes #102391.

What Problem This Solves

/export-session includes the transcript, full system prompt, and tool schemas. In the shipped v2026.7.1 release, any authorized sender could invoke it and pass an absolute or traversal path that OpenClaw wrote directly, including outside the workspace.

This PR now targets main and fixes both boundaries:

  • only the configured command owner may invoke /export-session or /export;
  • every output path is confined to a regular file inside the configured workspace.

Why This Change Was Made

The sibling /export-trajectory command already treats complete conversation exports as owner-only. The same owner gate is the right authorization boundary here, while independent filesystem confinement protects future callers too.

The port also moves the write policy into one focused module instead of leaving security-sensitive path behavior inside HTML generation. It uses the pinned @openclaw/fs-safe Root contract for canonical containment, symlink/path-alias rejection, private 0600 files, and atomic writes.

User Impact

  • Authorized non-owners can no longer export complete sessions.
  • Owners can use relative or absolute paths only when they resolve inside the workspace.
  • Explicit in-workspace regular files retain the existing overwrite behavior.
  • Generated names never overwrite an existing export; collisions receive a numeric suffix.
  • Invalid paths return a bounded error without exposing filesystem details.

Evidence

Current shipped reproduction:

  • GitHub release v2026.7.1 was published on 2026-07-13.
  • [email protected] is the current npm version.
  • The tag checks only isAuthorizedSender, then passes a caller-controlled resolved path to mkdir and writeFile without a workspace boundary.

Current-main port:

  • Final port head: f703c7109e8ab1b6f3a75015cf7220458837bbaa.
  • The final head passed 51 focused assertions plus the complete check:changed gate in a fresh, public-network, no-hydrate AWS Crabbox lease (run_dbe022a270cf). The bootstrap verified the exact SHA and rejected IMDS credentials before installing pinned Node and pnpm.
  • The exact-head hosted CI cohort passed: run 29348270773.
  • A fresh Codex autoreview against origin/main reported no accepted/actionable findings (patch is correct, confidence 0.90).
  • git diff --check and targeted oxfmt passed.

The real fs-safe boundary now has filesystem-backed regression coverage for:

  • relative and absolute in-workspace writes;
  • absolute paths expressed through a symlinked workspace root;
  • absolute and traversal escape rejection;
  • symlink escape rejection without changing the linked target;
  • explicit overwrite with private 0600 permissions;
  • collision-safe generated filenames.

The contributor's original exact-head Proxmox Crabbox proof exercised synthetic owner/helper identities plus absolute, traversal, in-workspace, overwrite, collision, and symlink-parent cases on the release-targeted implementation. The final main-targeted head additionally has both the exact-head isolated AWS proof and hosted CI cohort above.

Proof Scope

The shared command handler and real filesystem implementation are covered. No production session data or credentials were used. Individual chat transports are not re-tested because they all enter the same shared command handler.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 11, 2026
@VACInc
VACInc marked this pull request as ready for review July 11, 2026 21:09
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 11, 2026, 6:51 PM ET / 22:51 UTC.

Summary
The PR makes /export-session and /export owner-only and confines explicit and generated HTML export destinations to regular files inside the configured workspace.

PR surface: Source +5, Tests +92, Docs +3. Total +100 across 9 files.

Reproducibility: yes. Current main and the release base provide a high-confidence source reproduction: an authorized non-owner passes the command gate and the exporter writes a resolved caller-controlled path directly.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/auto-reply/reply/commands-export-session.test.ts, serialized state: src/auto-reply/reply/commands-export-session.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #102391
Summary: This PR is the direct candidate fix for the canonical linked security issue.

Members:

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

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Current main still contains the vulnerable authorization and direct-write path, so merging only this release-targeted PR leaves the primary branch exposed.
  • [P1] The owner-only gate intentionally removes session export access from configured authorized non-owner senders; that compatibility change must be accepted rather than inferred from technical correctness.

Maintainer options:

  1. Accept owner-only and port main (recommended)
    Merge the release fix and immediately land the equivalent security boundary on current main.
  2. Preserve helper access
    Keep fs-safe confinement but remove the owner gate if authorized helper exports are an intentional supported contract.
  3. Pause for feature-owner decision
    Hold the PR until the permanent authorization contract is confirmed.

Next step before merge

  • [P2] No patch defect is identified; maintainer approval of owner-only semantics and coordination of the required current-main port remain.

Maintainer decision needed

  • Question: Should full /export-session output be permanently restricted to command owners, in addition to workspace confinement?
  • Rationale: Workspace confinement is clearly required, but revoking configured authorized non-owner access is a compatibility and security-policy choice that requires maintainer intent.
  • Likely owner: steipete — He merged the original feature and has the strongest combined history across its command-policy and fs-safe boundaries.
  • Options:
    • Owner-only exports (recommended): Land owner gating and workspace confinement on the release branch and current main.
    • Authorized exports, safe paths: Preserve authorized non-owner access while enforcing canonical workspace confinement.
    • Pause session exports: Hold the command until its permanent privileged-access contract is settled.

Security
Cleared: The patch closes the demonstrated authorization and arbitrary-write paths without introducing a concrete security or supply-chain concern.

Review details

Best possible solution:

Adopt full session export as an owner-only privileged command, merge the verified release fix, and immediately land the patch-equivalent authorization and workspace-confinement change on current main.

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

Yes. Current main and the release base provide a high-confidence source reproduction: an authorized non-owner passes the command gate and the exporter writes a resolved caller-controlled path directly.

Is this the best way to solve the issue?

Yes technically. The owner gate matches the sibling sensitive export command, and the exact fs-safe dependency contract provides the required canonical workspace boundary; only the intentional compatibility policy remains for maintainer decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 50dd2db02058.

Label changes

Label justifications:

  • P0: Maintained code permits sensitive session exports to be written to arbitrary process-writable paths by an authorized non-owner.
  • merge-risk: 🚨 compatibility: The patch removes export access from configured authorized non-owner senders.
  • merge-risk: 🚨 security-boundary: The patch changes both privileged-command authorization and canonical filesystem containment for sensitive session data.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Exact-head live output demonstrates the after-fix authorization and filesystem behavior across escape, overwrite, collision, in-workspace, and symlink-parent cases.
  • proof: sufficient: Contributor real behavior proof is sufficient. Exact-head live output demonstrates the after-fix authorization and filesystem behavior across escape, overwrite, collision, in-workspace, and symlink-parent cases.
Evidence reviewed

PR surface:

Source +5, Tests +92, Docs +3. Total +100 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 35 30 +5
Tests 3 129 37 +92
Docs 2 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 169 69 +100

What I checked:

  • Current-main reproduction: Current main permits an authorized non-owner to reach the exporter, which resolves a caller-controlled path and writes it directly without a workspace boundary. (src/auto-reply/reply/commands-info.ts:326, 50dd2db02058)
  • Owner authorization: The patch applies the existing non-owner rejection helper to session export, matching the adjacent trajectory-export boundary. (src/auto-reply/reply/commands-info.ts:328, 9f8045b6d1c5)
  • Filesystem confinement: The exporter opens an fs-safe root at the configured workspace, uses non-overwriting create for generated names, uses write for deliberate explicit overwrites, and converts policy violations into a bounded user error. (src/auto-reply/reply/commands-export-session.ts:351, 9f8045b6d1c5)
  • Dependency contract: Direct inspection of the exact pinned @openclaw/[email protected] package confirmed canonical root containment, rejection of traversal and absolute outside-root targets, safe acceptance of absolute in-root targets, overwriting write, non-overwriting create, and policy error categorization. The repository patch changes only fsync fallback behavior. (pnpm-workspace.yaml:12, 50dd2db02058)
  • Regression coverage: Focused tests cover unauthorized and authorized non-owner rejection, owner success, explicit safe writes, policy-error rejection, and collision-safe generated filenames. (src/auto-reply/reply/commands-info.test.ts:145, 9f8045b6d1c5)
  • Real behavior proof: The PR body records exact-head Crabbox execution covering non-owner rejection, absolute and traversal escapes, relative and absolute in-workspace writes, explicit overwrite preservation, and symlink-parent rejection, with every expected result true. (9f8045b6d1c5)

Likely related people:

  • boris721: Authored the merged PR that introduced /export-session, full session contents, and custom output paths. (role: introduced feature; confidence: high; commits: add3afb7439e; files: src/auto-reply/reply/commands-export-session.ts, src/auto-reply/reply/commands-info.ts)
  • steipete: Committed the original feature, performed the immediate shared-command refactor, and has the strongest recent history around the fs-safe integration surface. (role: merger and adjacent owner; confidence: high; commits: add3afb7439e, f6111622e671; files: src/auto-reply/reply/commands-export-session.ts, src/infra/fs-safe.ts)
  • Tak Hoffman: Authored three focused fixes to session-export target-agent, store-path, and session-entry resolution. (role: recent area contributor; confidence: high; commits: 242a91bd0d78, 0c0cb1a3c0e6, a2dbc1b63cd8; files: src/auto-reply/reply/commands-export-session.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (4 earlier review cycles)
  • reviewed 2026-07-11T21:18:07.393Z sha 9f8045b6d1c53107020d42bb89ddbb2f7994849e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T21:27:14.802Z sha 9f8045b6d1c53107020d42bb89ddbb2f7994849e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T21:43:21.270Z sha 9f8045b6d1c53107020d42bb89ddbb2f7994849e :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T21:52:27.972Z sha 9f8045b6d1c53107020d42bb89ddbb2f7994849e :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 11, 2026
@steipete steipete self-assigned this Jul 14, 2026
@steipete
steipete force-pushed the fix/2026.7.1-export-session-boundaries branch from 9f8045b to ef5d837 Compare July 14, 2026 15:56
@steipete
steipete requested review from a team as code owners July 14, 2026 15:56
@steipete
steipete changed the base branch from release/2026.7.1 to main July 14, 2026 15:56
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 14, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready maintainer proof for f703c7109e8ab1b6f3a75015cf7220458837bbaa:

  • Ported the contributor fix to main, refactored all filesystem writes behind the pinned @openclaw/fs-safe boundary, and added the symlinked-workspace regression found during review.
  • Fresh public-network, no-hydrate AWS Crabbox run_dbe022a270cf verified the exact SHA, confirmed the IMDS credentials endpoint was unavailable, then passed 51 focused assertions from:
    • pnpm test src/auto-reply/reply/commands-export-session-file.test.ts src/auto-reply/reply/commands-export-session.test.ts src/auto-reply/reply/commands-info.test.ts src/commands/doctor-command-owner.test.ts
    • pnpm check:changed
  • Exact-head hosted CI passed: https://github.com/openclaw/openclaw/actions/runs/29348270773
  • Fresh exact-head Codex autoreview: no accepted/actionable findings; patch is correct, confidence 0.90.
  • git diff --check and targeted oxfmt passed.

Proof gap: individual transports were not repeated because all enter the same reviewed shared command handler. No production session data or credentials were used.

@steipete
steipete merged commit 6f0326a into openclaw:main Jul 14, 2026
120 of 122 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 15, 2026
…#104708)

* fix: prevent session exports outside workspace

* fix: support aliased workspace export paths

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…#104708)

* fix: prevent session exports outside workspace

* fix: support aliased workspace export paths

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

auto-reply: /export-session lets allowed non-owners write outside the workspace

2 participants