Repository navigation
fix: block out-of-root reply media in restricted sessions - #160696
eleqtrizit wants to merge 4 commits into
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 real behavior proof before merge. Reviewed September 29, 2026, 12:09 AM ET / 04:09 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch carries session permissions into agent reply-media handling, confines restricted local reads to the session root, adds an outbound staging guard, and extends boundary tests. Merge readiness⛔ Blocked before merge - 8 items remain Current main still lacks the reported boundary. The latest commit addresses the prior finding for a session row created before normalization, but a row created afterward can still escape the final staging check. The upgrade behavior also needs an owner decision. Priority: P0 Review scores
Verification
How this fits togetherAgent replies can contain local file paths. Reply-media handling checks the session and sender's read permissions, copies permitted files into managed outbound storage, and passes the result or a failure receipt to channel delivery. flowchart LR
A[Agent reply with media path] --> B[Current session permissions]
B --> C[Sender read policy]
C --> D[Local file reader]
D --> E{Read permitted?}
E -->|Yes| F[Outbound staging]
E -->|No| G[Delivery failure receipt]
F --> H[Channel reply]
Decision needed
Why: The documented boundary supports rejection, but it deliberately changes attachment delivery for existing operators; the PR author’s description does not itself accept that tradeoff for the product. Before merge
Findings
Agent review detailsSecurityNeeds attention: The new final-effect guard still has a reachable no-row authority window before outbound publication. PR surfaceSource +132, Tests +382. Total +514 across 19 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use a session-store-owned generation fact at final publication, preserve the intersection of session-root and sender-read permissions, and give operators an actionable attachment failure. Do we have a high-confidence way to reproduce the issue? Yes, from source: use a restricted session whose root is nested within the agent workspace and reply with a local path in the workspace but outside that root. Current main prepares that path without the branch’s session-root reader; this read-only review did not execute the flow. Is this the best way to solve the issue? No, not yet. Reusing the existing session and read-policy owners is the right direction, but the final guard must cover a newly appearing row and session-generation changes without adding synchronous database reads to delivery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5902fd290c4c. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Closing without merge after a precedent review. #152079 intentionally preserved external-channel staging while applying session-root restrictions to Gateway-owned media, including regression coverage that allows outside-root staging for non-Gateway channels. This change would therefore redefine shipped product policy rather than fix an established security boundary. Any universal session-root restriction should be proposed separately with explicit compatibility and design review. |
Summary
Restricted channel sessions could still read and stage reply-media outside their canonical session root, reuse stale session authority when the current row disappeared, and finish an outbound copy after permission revocation. This change carries the existing session permission mode and root through every reply-media owner, constrains the final reader, and revalidates live authority immediately before managed staging. It composes with the session-permission, dynamic-root, and Gateway media protections already on the base branch.
What Problem This Solves
src/auto-reply/reply/agent-runner-run.tsandsrc/auto-reply/reply/agent-runner-execution.tscreated media contexts without the run'spermissionModeorsessionRoot, so restricted modes fell back to broader config-level access.src/auto-reply/reply/reply-media-paths.tscould inherit the broader agent workspace even when the session root was narrower.src/auto-reply/reply/dispatch-from-config.prepare-delivery.tscould fall back to a captured session row when a current lookup returned no row.src/media/outbound-attachment.ts.The net effect was that model-authored local reply media could cross or outlive the active session filesystem boundary before being copied into managed outbound storage.
Why this design
fulland unset modes, and keep stricter config, tool-policy, sandbox, media-type, and media-size controls authoritative.Why this does not conflict with related PRs
The branch's merge base already contains the shipped behavior from these changes. Shared reply-media files are touched only to compose the existing owners and add current-authority invalidation at the staging sink.
Evidence
deny: ["read"]fulland unset modesfullwith stricter configfull→workspacechange during an awaited media loadfullauthority8aa29525f61pnpm tsgoandpnpm run check:changed --base upstream/mainpassed; branch autoreview found no P0/P1/P2 defects at 0.95 confidenceThe sink-level observations are the staged-media counts, rejected outside-root read, missing-row denial, failure receipt, and commit guard firing before
saveMediaBuffercan persist bytes.SDK / caller upgrade contract
fulland unset sessions retain their existing attachment behavior.workspaceOnlysessions retain access within the configured agent workspace.Testing
src/auto-reply/reply/agent-runner.media-ownership.test.ts,src/auto-reply/reply/reply-media-paths.test.ts,src/auto-reply/reply/dispatch-from-config.media-ownership.test-utils.ts, andsrc/media/outbound-attachment.test.ts.8aa29525f61; the dispatch suite passed 138/138 and the creation-then-revocation case used the real media normalizer and outbound staging sink.pnpm tsgo.pnpm run check:changed --base upstream/mainwith all 26 core test type graphs and anEXIT=0result.