Repository navigation
fix(media): bind local media roots to the active session - #144347
Conversation
Sandboxed sessions could read sibling sandbox and shared host workspace files through local media authorization: the read allowlist still trusted the shared sandboxes/workspace parents, source-parent expansion re-granted any directory the caller named, and the attachment/understanding pipeline never received the session filter. - confine base and expansion-added media roots so shared isolation parents (and the shared workspace for sandboxed sessions) never re-enter the allowlist; own sandbox and explicitly granted workspaces stay readable - use session-safe default roots for attachment/understanding caches - gate host-workspace media staging on the sandbox workspaceAccess mode: with the default "none" the session's media workspace is its sandbox, and host-workspace paths fail closed via the sandbox boundary; ro/rw keep staging since the workspace is mounted
|
🦞👀 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 17, 2026, 3:14 AM ET / 07:14 UTC (Revision 11). ClawSweeper reviewWhat this changesThe PR confines attachment reads to session-appropriate folders, preserves those restrictions through attachment caches, and checks workspace access before staging local reply files. Merge readiness⛔ Blocked before merge - 3 items remain This remains a useful security repair absent from fetched main and the latest release. No blocking introduced defect was found; the previous cache finding is resolved, and exact-head security review accepts the bounded repair and compatibility tradeoff. Priority: P0 Review scores
Verification
How this fits togetherOpenClaw’s media pipeline turns attachment paths into bytes for agent input or outbound delivery. Session workspace roots and caller-held read capabilities determine which local files that pipeline may consume. flowchart TD
A[Attachment or reply path] --> C[Media access policy]
B[Session workspace and read capability] --> C
C --> D{Path authorized?}
D -->|Yes| E[Checked file read]
E --> F[Agent input or staged attachment]
D -->|No| G[Recorded attachment failure]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +129, Tests +255. Total +384 across 13 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the approved shared media-policy repair, preserving explicit session grants and keeping the documented inbound limitation outside its security claims. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the source-parent reauthorization path on fetched main, and the PR records corresponding production-owner observations. This read-only review did not execute a reproduction or tests. Is this the best way to solve the issue? Yes, the patch repairs the existing authorization owner and cache consumers without adding a competing policy or configuration surface; its compatibility and scope decisions have exact-head security acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5f17f893af58. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
…andboxed sessions Thread the caller's session workspace into the session-safe default media roots so the shared workspace parent is removed whenever the session workspace lives elsewhere (an active sandbox). Sessionless callers keep the legacy grant; the caller's own workspace is merged explicitly.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…he construction MediaAttachmentCache merged sessionless default roots back into caller-provided scoped roots, restoring the shared workspace/sandbox parents that resolveMediaAttachmentLocalRoots had removed for sandboxed sessions. Production consumers now pass includeDefaultLocalPathRoots: false so the scoped root set is authoritative through the final read. Adds final-read regression coverage through the cache getBuffer path and SDK expansion-branch coverage for trusted session-context callers.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…icit-root assertion Chat-send display finalization is not a model-read boundary; restoring the pre-#144347 unconditional source-parent expansion there fixes transcript- adjacent media display (chat.directive-tags suite) and keeps appendLocalMediaParentRoots production-used for the dependency check. Model-facing paths (media understanding, reply staging) keep the session confinement and workspaceAccess gating.
…tion The assertion-safety ratchet only counts a // SAFETY: comment on the assertion line or immediately above it.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
vincentkoc
left a comment
There was a problem hiding this comment.
Secops-qualified at this head. Stable physical aliases now intersect through fs-safe, normal outbound dispatch carries the canonical workspace policy, and an explicit caller-backed sandbox grant is no longer mislabeled as unmounted.
Merge after exact-head CI completes and the queued ClawSweeper refresh is clear.
vincentkoc
left a comment
There was a problem hiding this comment.
Secops approved at exact head 7b0b289. The current-main merge is conflict-free and preserves the hardened resolved-media boundary: canonicalized roots, caller read policy, sandbox mount proof, and explicit error/reply outcomes.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Secops closeout: the data-model rank move does not apply. The diff does not change any persisted representation, key, schema, or migration; persistLocalReplyMedia keeps the existing attachment artifact shape and only receives a source root selected by the per-turn filesystem policy. Compatibility and inbound-workspace residual risks remain explicitly accepted. @clawsweeper re-review |
|
Merged via squash.
|
…4347) * fix(media): bind local media roots to the active session Sandboxed sessions could read sibling sandbox and shared host workspace files through local media authorization: the read allowlist still trusted the shared sandboxes/workspace parents, source-parent expansion re-granted any directory the caller named, and the attachment/understanding pipeline never received the session filter. - confine base and expansion-added media roots so shared isolation parents (and the shared workspace for sandboxed sessions) never re-enter the allowlist; own sandbox and explicitly granted workspaces stay readable - use session-safe default roots for attachment/understanding caches - gate host-workspace media staging on the sandbox workspaceAccess mode: with the default "none" the session's media workspace is its sandbox, and host-workspace paths fail closed via the sandbox boundary; ro/rw keep staging since the workspace is mounted * fix(media): drop shared workspace from inbound attachment roots for sandboxed sessions Thread the caller's session workspace into the session-safe default media roots so the shared workspace parent is removed whenever the session workspace lives elsewhere (an active sandbox). Sessionless callers keep the legacy grant; the caller's own workspace is merged explicitly. * fix(media): keep session-scoped attachment roots authoritative at cache construction MediaAttachmentCache merged sessionless default roots back into caller-provided scoped roots, restoring the shared workspace/sandbox parents that resolveMediaAttachmentLocalRoots had removed for sandboxed sessions. Production consumers now pass includeDefaultLocalPathRoots: false so the scoped root set is authoritative through the final read. Adds final-read regression coverage through the cache getBuffer path and SDK expansion-branch coverage for trusted session-context callers. * fix(media): keep display-layer source-parent expansion; annotate explicit-root assertion Chat-send display finalization is not a model-read boundary; restoring the pre-openclaw#144347 unconditional source-parent expansion there fixes transcript- adjacent media display (chat.directive-tags suite) and keeps appendLocalMediaParentRoots production-used for the dependency check. Model-facing paths (media understanding, reply staging) keep the session confinement and workspaceAccess gating. * fix(media): place SAFETY annotation on the line adjacent to the assertion The assertion-safety ratchet only counts a // SAFETY: comment on the assertion line or immediately above it. * fix(media): canonicalize session-safe roots * fix(media): retain explicit sandbox read capability --------- Co-authored-by: Vincent Koc <[email protected]>
Summary
A sandboxed session could make the Gateway read files outside its sandbox — sibling sandboxes and the shared host workspace — through the media pipelines, even with
workspaceAccess: "none"(the default). #143521 made base media roots session-scoped, but three construction paths still re-granted the shared parents downstream. This PR closes those paths, completing #143521 without touching #138856's display layer.What was wrong
The sandbox media-read contract had three gaps — each re-introducing a parent that #143521 had removed:
src/media/local-roots.ts) — naming a file re-authorized its directory, so naming<state>/sandboxes/<other>/secret.txtre-added the sibling sandbox and the sharedsandboxesparent to the allowlist.src/media-understanding/,src/plugin-sdk/) — attachment-cache roots still defaulted to the shared sandbox parent, and the cache merged sessionless default roots back over session-scoped ones, restoring them at construction.src/auto-reply/reply/reply-media-paths.ts) — host-workspace absolute paths were staged regardless ofworkspaceAccess, sononedidn't mean "not mounted".Net effect: model-steered media paths in a sandboxed session could read sibling session sandboxes and host-workspace files through both the outbound reply and inbound attachment pipelines.
Why this design
workspaceAccessis the contract:none(default) → host-workspace paths fail closed through the sandbox boundary;ro/rw→ the workspace is mounted and staging keeps working.Why this does not conflict with #143521 or #138856
These PRs govern different layers of the same principle — media access follows the session's actual workspace context:
ui/and nosrc/gateway/files; the preview-serving path (assistant-media-policy,control-ui,http-image-response) is not modified, and its test suites pass on this branch.Concretely: what a browser may display (#138856) and what a sandboxed pipeline may read (#143521 + this PR) are separate checks with separate owners. Narrowing the latter does not reopen the former — a project-worktree session keeps its own workspace roots in both layers. The two PRs do share
src/media/local-roots.ts; our branch is based on a revision that already includes #138856, and the changes compose (additive filtering helpers vs. display policy).Evidence (final effects on this head)
Exercised through the real production owners — unmocked sandbox resolution, real sink chain, real staging — via throwaway state dirs (private reproduction retained in the advisory):
workspaceAccessnonenonenonerw(mounted)rwOutbound reader (
resolveOutboundAttachmentFromUrl) and attachment-cachegetBufferobservations match: allowed reads succeed; sibling/unmounted/outside-roots reads are rejected before consumption.SDK / caller upgrade contract
getAgentScopedMediaLocalRoots/…ForSources(plugin-sdk) keep their existing contract: trusted session context keeps that session's access; callers that omit session context now fail closed for sandbox files rather than silently keeping shared-parent grants.plugin-sdk/media-local-roots.test.ts, including the expansion branch with trusted context (own nested sandbox file readable; sibling blocked).Boundary decisions requested from security owners
Three explicit asks so this PR can merge with clear ownership (posted as a comment for @openclaw/openclaw-secops):
Testing
getBufferreads),workspaceAccess-gated staging (none blocks / rw stages), SDK expansion-branch contract.