Skip to content

fix(media): honor sender tool policy for outbound file reads - #125950

Merged
joshavant merged 6 commits into
mainfrom
security/enforce-sender-media-policy
Aug 18, 2026
Merged

joshavant merged 6 commits into
mainfrom
security/enforce-sender-media-policy

Conversation

@joshavant

@joshavant joshavant commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where operators using global or per-agent toolsBySender rules to deny file reads could still have a model-selected local file attached through final replies or message actions.

Why This Change Was Made

Outbound media access now applies the same canonical requester policy used by ordinary tools before granting local-file access. Denied requesters retain only the established managed-artifact roots, while workspace-only filesystem policy continues to allow legitimate workspace attachments. The source session remains authoritative for channel-qualified rules, and the host-minted message-action capability carries all supported sender aliases without changing public configuration or protocol behavior.

User Impact

Sender-scoped file-read restrictions now apply consistently to outbound attachments. Allowed senders, workspace-only workflows, and managed generated media continue to work normally.

Evidence

Before the change, a focused probe showed the ordinary read tool denied while outbound media still exposed a reader and expanded the selected file's parent directory. Review of the real loader then identified a second path: an absent custom reader falls back to direct reads from retained baseline roots. After the change, an attachment-level regression proves that a denied workspace file is rejected with no disclosed bytes while a managed tool artifact remains loadable.

Validation completed locally:

  • Focused media, capability, recovery, and message-tool suites passed.
  • Final-reply, delivery, message-action, matcher, managed-path, and requester-policy sibling suites: 289 tests passed.
  • pnpm check:changed passed, including core/core-test typechecking, lint, import-cycle, policy, and database guards.
  • Diff-scoped autoreview reported no actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@joshavant
joshavant force-pushed the security/enforce-sender-media-policy branch from f6363b4 to 0e702ce Compare August 18, 2026 19:05
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 6:39 PM ET / 22:39 UTC.

ClawSweeper review

What this changes

The PR makes outbound attachment reads honor sender-specific read restrictions by carrying trusted sender aliases into final-reply and message-action media policy.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking defect remains on the exact PR head. The prior gateway attachment-hydration gap is repaired; this maintainer-authored, security-boundary PR should receive normal owner review before merge.

Priority: P1
Reviewed head: caf64c40b859e4e7ca15ff844f87addeb16bfd75

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation is a focused, well-covered repair with no remaining actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its focused regression coverage remains useful supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its focused regression coverage remains useful supplemental evidence.
Evidence reviewed 6 items Canonical media-policy owner: The PR resolves group and sender policy together, removes workspace/source roots and the host reader on denial, and retains only managed outbound/tool roots.
Gateway hydration repair: Gateway message actions derive the scoped access from the signed requester identity and use it for send attachment hydration before dispatching reader-free access downstream.
Sibling execution path: Direct message-tool actions construct the same sender-scoped access before attachment hydration, including source-session channel and account context.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/server-methods/send.test.ts --testNamePattern "applies signed sender aliases"

Result: PASS (completed)

runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125950-mczKE8/target$ node scripts/run-vitest.mjs src/gateway/server-methods/send.test.ts --testNamePattern "ap
plies signed sender aliases"
[test] starting test/vitest/vitest.gateway.config.ts
node scripts/run-vitest.mjs src/gateway/server-methods/send.test.ts --testNamePattern "applies signed sender aliases"

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-125950-mczKE8/target

 ✓  gateway-methods  ../../src/gateway/server-methods/send.test.ts (111 tests | 109 skipped) 1269ms

 Test Files  1 passed (1)
      Tests  2 passed | 109 skipped (111)
   Start at  22:40:28
   Duration  15.20s (transform 12.18s, setup 1.03s, import 12.53s, tests 1.27s, environment 0ms)

[test] passed 1 Vitest shard in 21.25s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125950-mczKE8/target$ node scripts/run-vitest.mjs src/gateway/server-methods/send.test.ts --testNamePattern "ap
plies signed sender aliases"


































Assertions:

  • PASS expect_output: 1 passed

How this fits together

Outbound media access turns an agent-selected local path into an attachment before channel delivery. It receives trusted sender identity and policy context, then either permits scoped file access or retains only managed generated-media roots.

flowchart LR
  A[Inbound sender identity] --> B[Signed turn context]
  B --> C[Sender tool policy]
  D[Reply or message action] --> E[Outbound media access]
  C --> E
  E --> F[Attachment hydration]
  F --> G[Channel delivery]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 61 net lines across the signed requester-identity and media-access boundary; a future simplification must preserve alias-based denial and managed-artifact access.
  • Complete next step (P2) - A protected maintainer security-boundary PR needs normal owner review; no bounded mechanical repair remains.
Agent review details

Security

None.

PR surface

Source +61, Tests +289. Total +350 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 12 160 99 +61
Tests 6 291 2 +289
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 451 101 +350

Review metrics

Metric Value Why it matters
Production versus regression coverage production +160/-99 (net +61), tests +291/-2 The production growth carries signed sender aliases and restricted managed-root selection; the added tests cover the previously missed gateway boundary.

Merge-risk options

Maintainer options:

  1. Land after security-owner review (recommended)
    Accept the reviewed implementation after a maintainer confirms the scoped-root behavior is the intended sender-policy contract.

Technical review

Best possible solution:

Keep one canonical sender-policy decision in outbound media access, with signed aliases propagated only through the existing turn capability and managed artifacts remaining available after denial.

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

Yes—current-main source leaves gateway attachment hydration outside the sender-alias policy, while the exact-head gateway and media tests define a focused denied-workspace versus managed-artifact path.

Is this the best way to solve the issue?

Yes—the patch repairs the owner boundary by deriving one scoped media-access object before hydration and dispatch rather than trusting request-supplied sender fields.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its focused regression coverage remains useful supplemental evidence.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: This repairs a sender-scoped local-file authorization path used by outbound attachments.
  • merge-risk: 🚨 security-boundary: Merging changes which local files a sender-restricted agent may attach.
  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its focused regression coverage remains useful supplemental evidence.

Evidence

What I checked:

  • Canonical media-policy owner: The PR resolves group and sender policy together, removes workspace/source roots and the host reader on denial, and retains only managed outbound/tool roots. (src/media/read-capability.ts:37, caf64c40b859)
  • Gateway hydration repair: Gateway message actions derive the scoped access from the signed requester identity and use it for send attachment hydration before dispatching reader-free access downstream. (src/gateway/server-methods/send.ts:1002, caf64c40b859)
  • Sibling execution path: Direct message-tool actions construct the same sender-scoped access before attachment hydration, including source-session channel and account context. (src/infra/outbound/message-action-runner.ts:382, caf64c40b859)
  • Boundary regression coverage: The gateway test covers signed aliases for send and sendAttachment, denied workspace loading with no buffered bytes, and permitted managed-artifact loading. (src/gateway/server-methods/send.test.ts:4192, caf64c40b859)
  • Current-main provenance: The pre-PR gateway path was attributed by blame to the current-main commit that only derived media access for send and omitted sender aliases from the hydration path. (src/gateway/server-methods/send.ts:1005, e15d5329fa4b)
  • Release/main status: The PR head is unmerged and no release tag contains it; the latest supplied release predates this fix. (caf64c40b859)

Likely related people:

  • Peter Steinberger: Blame attributes the pre-PR media-access and gateway hydration path to this recent mainline commit. (role: current-main policy-path author; confidence: high; commits: e15d5329fa4b, 28e681c92f0c; files: src/media/read-capability.ts, src/gateway/server-methods/send.ts)
  • joshavant: Recent merged gateway-routing work and this PR’s exact-head repair both cover the message-action boundary. (role: recent gateway contributor; confidence: high; commits: 49e7c12d613b, caf64c40b859; files: src/gateway/server-methods/send.ts, src/gateway/message-action-turn-capability.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain the normal security-owner merge review for this protected boundary.

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-18T19:13:15.114Z sha 0e702ce :: found issues before merge. :: [P1] Block fallback reads after a sender policy denies read
  • reviewed 2026-08-18T19:38:07.125Z sha ac768a6 :: found issues before merge. :: [P1] Forward trusted sender aliases into Gateway media policy
  • reviewed 2026-08-18T20:19:06.330Z sha c56b112 :: found issues before merge. :: [P1] Preserve wildcard sender policy without aliases | [P1] Apply scoped media roots to non-send Gateway actions
  • reviewed 2026-08-18T20:49:12.700Z sha 5dadc35 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T21:14:40.697Z sha f8450db :: found issues before merge. :: [P1] Scope Gateway attachment hydration to sender policy
  • reviewed 2026-08-18T21:38:49.187Z sha ae7cc42 :: found issues before merge. :: [P1] Use sender-scoped roots for Gateway attachment hydration

@joshavant
joshavant requested a review from a team as a code owner August 18, 2026 19:30
@openclaw-barnacle openclaw-barnacle Bot added docker Docker and sandbox tooling size: M and removed size: S labels Aug 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 18, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@joshavant
joshavant force-pushed the security/enforce-sender-media-policy branch from 5dadc35 to f8450db Compare August 18, 2026 21:07
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Aug 18, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 18, 2026
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@joshavant
joshavant merged commit d7fe595 into main Aug 18, 2026
228 checks passed
@joshavant
joshavant deleted the security/enforce-sender-media-policy branch August 18, 2026 22:49
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…w#125950)

* fix(media): enforce sender policy for outbound reads

* fix(media): block denied attachment fallbacks

* fix(gateway): preserve sender aliases for media policy

* fix(media): scope wildcard and attachment actions

* test(gateway): prove denied media stays unbuffered

* fix(gateway): scope send attachment hydration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

1 participant