Repository navigation
fix(media): honor explicit read policies for reply attachments - #184964
Conversation
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR applies explicit global and per-agent read policies before granting workspace attachment access. Example: Agent writer replies with MEDIA: output/report.txt while tools.deny contains read.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current-main read-policy bypass with a focused change, and no introduced correctness or security defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe media-access owner converts configuration and requester context into filesystem roots and readers used by reply preparation, attachment staging, and channel delivery. flowchart LR
A[Reply media directive] --> B[Reply preparation]
C[Global and agent policies] --> D[Media access owner]
E[Group and sender policies] --> D
B --> D
D --> F[Bounded file loader]
F --> G[Outbound attachment store]
G --> H[Channel delivery]
Technical reviewBest possible solution: Intersect explicit read policies in the existing media-access owner while retaining its established managed-artifact exception. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the missing intersection, and the supplied base/head capture demonstrates its filesystem effect; this read-only review executed no target code. Is this the best way to solve the issue? The patch is the smallest complete repair: canonical policy resolution feeds the existing denial branch without new state, wrappers, or competing authorization paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 77c12a45cd59. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +15, Tests +63. Total +78 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 26, 2026, 4:24 PM ET / 20:24 UTC (Revision 3). |
|
@clawsweeper explain For the current head f9ce6c9, please clarify the remaining proof contract before I build an unrelated upgrade harness. The complete authored delta is one runtime read-policy intersection plus the integration matrix; it changes no config key/default, stored representation, persistence writer, migration, or SDK signature. I will supply redacted terminal capture through the real directive parser, reply-media preparer, file loader and outbound store, showing authorized staging, global/agent denial with no copied workspace bytes, and managed-artifact preservation (including a pre-fix comparison). Does this final-effect harness satisfy the requested runtime artifact, and is any separate installed-upgrade artifact actually required for this unchanged persistence/config surface? Please distinguish intentional enforcement of existing read restrictions from stored-data migration. No readiness or merge is requested. |
|
ClawSweeper status:
|
|
ClawSweeper assist: Yes—the described zero-mock harness would satisfy the runtime-capture ask at the outbound-staging boundary, provided its captured execution demonstrates those results against exact head A separate installed-upgrade artifact is not required for the supplied runtime-only delta: enforcing existing read restrictions changes authorization behavior, not stored data. No config key/default, persistence writer/format/schema, or migration changes are shown. Evidence:
Minimum missing proof is the actual redacted capture, with the harness source or reproducible command, environment, exact head and pre-fix source identity. Show allowed bytes, zero workspace bytes and zero new outbound files for the six denied-policy cases, retained managed bytes, and unchanged authored config. State that this proves local staging behavior; channel delivery remains unexercised. Suggested next action: Add that reproducible runtime capture and its scope to the main PR body; no unrelated upgrade harness is needed on the supplied evidence. Source: #184964 (comment) |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge recordSummary: Applies explicit global and per-agent read restrictions to workspace reply attachments. Allowed attachments and managed generated artifacts remain available. Decision Reason for Merge: Merged because production-path before/after evidence demonstrates the authorization bypass is fixed, and ClawSweeper accepted the proof with no findings or before-merge requirements. Compatibility Checks Done: 130 focused tests, production and owning-test typechecks, and targeted static checks passed. Nine runtime cases verified denied reads, allowed attachments, managed output, and unchanged configuration. Broad hosted CI remains skipped while draft. |
Restore CLI message sends for agents with their own tool policies while preserving attachment read restrictions and Template consent validation. Refs #184964. Reviewed-by: @shakkernerd
) Restore CLI message sends for agents with their own tool policies while preserving attachment read restrictions and Template consent validation. Refs openclaw#184964. Reviewed-by: @shakkernerd
Summary
Apply explicit global and per-agent file-read policy before granting outbound media access to workspace files. Reuse the existing denied-reader path, preserving managed generated media and normal attachment delivery alongside the earlier sender-policy and channel-owned Markdown work.
What Problem This Solves
What this Problem Solves — Fixes workspace files being attached in final replies even when the operator has explicitly excluded file reads. The affected admission decision is in
src/media/read-capability.ts; reply staging and loading consume the roots it grants.What was wrong
src/media/read-capability.tschecked group and sender read rules when selecting workspace roots, but omitted explicit global and agent read policies.src/auto-reply/reply/reply-media-paths.tsandsrc/media/web-media.tscould therefore stage workspace bytes through the ordinary attachment loader despite those restrictions.The fix makes the existing media-access owner apply the missing policies before any workspace access is granted.
User Impact
Explicit read denials and allow lists excluding read now also restrict workspace attachments. Operators intentionally using a restrictive allow list must include read when workspace-file attachment access is intended. Managed generated artifacts, read-enabled workspace-only workflows, messaging profiles alone, and remote media keep their existing behavior. No new configuration keys, defaults, migrations, or SDK signatures are introduced.
Why This Change Was Made
Why this does not conflict with related PRs
The current base retains these behaviors. Historical merge commits are not ancestors of this checkout, so this statement is based on inspected current code, not assumed merge ancestry. Only the shared media-access owner and its integration suite change.
Evidence
Evidence of Fix
node --import ./scripts/tsx.mjs scripts/test-projects.mts src/media/read-capability.test.ts src/media/read-capability.workspace-access.test.tsSink-level assertions inspect staged bytes and the outbound directory, rather than only policy booleans. A separate standalone Node process additionally exercised the real production parser, preparer, loader and store with zero mocks, measuring actual bytes copied and new outbound files. Six restricted cases changed from 26 workspace bytes / one new file before the fix to zero bytes / zero files at the reviewed head; allowed, workspace-only and messaging-profile controls still copied the exact 26-byte canary. All nine cases preserved exact 24-byte managed output and byte-identical authored config. This is final-effect source-runtime evidence, not a real channel API, model-driven session, installed-package upgrade or full Gateway transport claim. Read-only reviewer clarification confirms this zero-mock final-effect harness satisfies the staging-boundary proof contract and that no separate installed-upgrade artifact is required for this runtime-only delta.
Reproducible standalone harness and captured terminal output
Reviewed head:
f9ce6c9131888e327a309a2f0239778027e55a2a. Before-fix comparison temporarily substituted onlysrc/media/read-capability.tsfrom parent2045985b82707f15130d3ceb3c4fb1fe1fe61737, then restored it and verifiedgit diff HEADempty. All other production sources are identical for this two-file patch; the changed test file is not imported by this standalone harness.Command:
node --import ./scripts/tsx.mjs <scratch>/media-proof.mts basewith pre-fix owner, then the same command withheadand the fixed owner (Node 26.12.1). Afinallyblock removes only the isolated synthetic workspace/state. No credentials, channel account, external endpoint, mocks or Vitest runtime is involved.Harness SHA-256:
d460c49071b5d1d9b1844772696e9d147a6f99b1a238d8d5b7bc7b9f73054207.Boundary decisions requested from media/security owners
Testing
node --import ./scripts/tsx.mjs scripts/test-projects.mts src/media/load-options.test.ts src/media/local-roots.test.ts src/media/web-media.test.ts src/auto-reply/reply/reply-media-paths.test.ts src/auto-reply/reply/reply-media-paths.ssh.test.ts— all five files passed.pnpm tsgo:core— passed.node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/media/read-capability.workspace-access.test.ts"]'— messaging graph passed.git diff --check— passed.