Skip to content

fix(media): honor sender policy for host media reads - #64459

Merged
drobison00 merged 10 commits into
openclaw:mainfrom
eleqtrizit:fix/outbound-media-read-policy
Apr 10, 2026
Merged

drobison00 merged 10 commits into
openclaw:mainfrom
eleqtrizit:fix/outbound-media-read-policy

Conversation

@eleqtrizit

Copy link
Copy Markdown
Contributor

Summary

  • Thread outbound host-media read decisions through sender and group context
  • Keep host-local attachment reads aligned with existing read tool policy checks

Changes

  • Added a sender-aware gate in src/media/read-capability.ts so host readFile support now intersects the existing group tool policy for read
  • Passed sessionKey, channel/account context, and requester sender id from outbound message paths into media access resolution
  • Added regression coverage proving sender-denied group members no longer receive host read capability while allowed senders still do

Validation

  • Ran corepack pnpm test src/media/read-capability.test.ts
  • Ran corepack pnpm test src/infra/outbound/message-action-runner.plugin-dispatch.test.ts
  • Ran corepack pnpm build
  • Ran local agentic review via claude -p "/review"; the command returned a PR-list approval prompt instead of a local diff review, so I completed manual diff review after the local test/build gates
  • Pre-commit hook passed pnpm check during scripts/committer

Notes

  • This keeps the change narrow to outbound host-media capability creation and does not alter unrelated attachment loading behavior
  • No existing fix PR or GHSA private-fork patch was visible from the accessible GitHub surfaces for this advisory

@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Apr 10, 2026
@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR threads sender and group context into outbound host-media read capability resolution, so that a group member explicitly denied the read tool via toolsBySender policy can no longer receive a readFile capability for host-local attachments. The change adds isAgentScopedHostMediaReadAllowed in read-capability.ts, propagates requesterSenderId (and the full sender identity tuple) through dispatch-from-config, followup-runner, route-reply, deliver, and outbound-send-service, and adds regression coverage for the denied-sender and allowed-sender cases.

Confidence Score: 5/5

Safe to merge — the sender-policy gate is correctly implemented and all production call sites consistently propagate sender context.

No P0 or P1 findings. The core logic in read-capability.ts correctly layers sender/group policy on top of the existing global tool-FS-root check. All major outbound paths (deliver, outbound-send-service, message-action-runner, route-reply, dispatch-from-config, followup-runner) consistently thread requesterSenderId through. The single P2 comment is a test-style observation (passing messageProvider alongside sessionKey) that does not affect correctness.

src/media/read-capability.test.ts — minor test-shape inconsistency with production call sites (P2 only).

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/media/read-capability.test.ts
Line: 52-53

Comment:
**Test passes `messageProvider` alongside `sessionKey`**

Every production call site sets `messageProvider: undefined` when `sessionKey` is present (e.g. `deliver.ts`, `outbound-send-service.ts`, and `message-action-runner.ts` all gate on `params.session?.key ? undefined : channel`). Functionally the tests are correct — `resolveGroupToolPolicy` uses `messageProvider ?? sessionContext.channel` and both paths resolve to `"whatsapp"` — but the tests don't precisely mirror the real call shape, which could hide a future regression if that precedence order ever changes. Consider omitting `messageProvider` from tests that supply a `sessionKey` to keep them aligned with the production call sites.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(media): preserve account policy fall..." | Re-trigger Greptile

Comment thread src/media/read-capability.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 100fca7681

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/infra/outbound/deliver.ts Resolved
@drobison00
drobison00 force-pushed the fix/outbound-media-read-policy branch from 100fca7 to 6efc7a4 Compare April 10, 2026 19:04
…der when sessionKey is set

Addresses P2 review: production call sites pass messageProvider: undefined
when sessionKey is present; tests should mirror that so regressions in
the precedence order are caught.
@drobison00
drobison00 merged commit c949af9 into openclaw:main Apr 10, 2026
8 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6348e1f64d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +571 to +573
sessionKey: params.session?.key,
messageProvider: params.session?.key ? undefined : channel,
accountId: params.session?.requesterAccountId ?? accountId,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist requester policy context for queued retries

Fresh evidence in this commit is that outbound media access now depends on params.session requester metadata (sessionKey/sender/account), but recovery replay still rebuilds deliveries from QueuedDeliveryPayload without any session/requester fields (delivery-queue-storage.ts + delivery-queue-recovery.ts). After a crash/restart, retries reach this branch with params.session unset and evaluate host-media read policy against destination-only context, so sender-scoped denies (for example toolsBySender on read) can be bypassed on replay; queue entries need to persist and replay requester session metadata so retry behavior matches the initial attempt.

Useful? React with 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* fix(media): honor sender policy for host media reads

* fix(media): clarify host read group policy gating

* fix(media): forward sender identity for outbound reads

* fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching

* fix(media): preserve requester provider for host read policy

* fix(media): forward full sender identity through followup and core send paths

* fix(media): forward requester session/account context through core send fallback

* fix(media): preserve account policy fallback for requester-scoped host reads

* chore(changelog): add outbound media sender-policy entry

* fix(media): align test call shape with production — omit messageProvider when sessionKey is set

Addresses P2 review: production call sites pass messageProvider: undefined
when sessionKey is present; tests should mirror that so regressions in
the precedence order are caught.

---------

Co-authored-by: Devin Robison <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* fix(media): honor sender policy for host media reads

* fix(media): clarify host read group policy gating

* fix(media): forward sender identity for outbound reads

* fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching

* fix(media): preserve requester provider for host read policy

* fix(media): forward full sender identity through followup and core send paths

* fix(media): forward requester session/account context through core send fallback

* fix(media): preserve account policy fallback for requester-scoped host reads

* chore(changelog): add outbound media sender-policy entry

* fix(media): align test call shape with production — omit messageProvider when sessionKey is set

Addresses P2 review: production call sites pass messageProvider: undefined
when sessionKey is present; tests should mirror that so regressions in
the precedence order are caught.

---------

Co-authored-by: Devin Robison <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(media): honor sender policy for host media reads

* fix(media): clarify host read group policy gating

* fix(media): forward sender identity for outbound reads

* fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching

* fix(media): preserve requester provider for host read policy

* fix(media): forward full sender identity through followup and core send paths

* fix(media): forward requester session/account context through core send fallback

* fix(media): preserve account policy fallback for requester-scoped host reads

* chore(changelog): add outbound media sender-policy entry

* fix(media): align test call shape with production — omit messageProvider when sessionKey is set

Addresses P2 review: production call sites pass messageProvider: undefined
when sessionKey is present; tests should mirror that so regressions in
the precedence order are caught.

---------

Co-authored-by: Devin Robison <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(media): honor sender policy for host media reads

* fix(media): clarify host read group policy gating

* fix(media): forward sender identity for outbound reads

* fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching

* fix(media): preserve requester provider for host read policy

* fix(media): forward full sender identity through followup and core send paths

* fix(media): forward requester session/account context through core send fallback

* fix(media): preserve account policy fallback for requester-scoped host reads

* chore(changelog): add outbound media sender-policy entry

* fix(media): align test call shape with production — omit messageProvider when sessionKey is set

Addresses P2 review: production call sites pass messageProvider: undefined
when sessionKey is present; tests should mirror that so regressions in
the precedence order are caught.

---------

Co-authored-by: Devin Robison <[email protected]>
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* fix(media): honor sender policy for host media reads

* fix(media): clarify host read group policy gating

* fix(media): forward sender identity for outbound reads

* fix(media): propagate non-id sender fields through outbound session for e164/username/name policy matching

* fix(media): preserve requester provider for host read policy

* fix(media): forward full sender identity through followup and core send paths

* fix(media): forward requester session/account context through core send fallback

* fix(media): preserve account policy fallback for requester-scoped host reads

* chore(changelog): add outbound media sender-policy entry

* fix(media): align test call shape with production — omit messageProvider when sessionKey is set

Addresses P2 review: production call sites pass messageProvider: undefined
when sessionKey is present; tests should mirror that so regressions in
the precedence order are caught.

---------

Co-authored-by: Devin Robison <[email protected]>
@eleqtrizit eleqtrizit self-assigned this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants