send_file confinement is symlink-blind and re-opens the file after checking it #1398

Closed
opened 2026-10-27 13:40:14 +00:00 by sam · 0 comments
Owner

internal/tools/builtin/confinement.go ResolveReadable applies exactly the read tool's policy (resolvePath + isReadConfined), which is purely lexical: filepath.Abs/Rel, never EvalSymlinks. A symlink inside the workspace pointing at /etc/shadow passes the check, and the telegram sender then opens att.Path with no confinement check of its own, in a different goroutine after the turn. There is also a real TOCTOU window -- prepare stats/opens/closes, SendMedia re-stats and re-opens later.

The policy is unchanged from the read tool, so this is not a new hole; what changed is the consequence. The read tool caps at 5MB into the operator's own context; send_file ships up to 50MB OUT to a chat. The shell tool has never been confined either, so a model that wants the bytes already has them.

Decide: either resolve symlinks in ResolveReadable (which changes read-tool behaviour too, and may break legitimate symlinked workspaces), or document the caveat explicitly and stop claiming 'sending cannot reach what reading cannot' without it.

Found by adversarial review of 9a45fbb.

Acceptance Criteria

Either the symlink case is closed at the resolver, or the limitation is written down where the claim is made (confinement.go doc comment and sendfile package doc).

Close reason

ResolveReadable now follows symlinks and re-checks the real path (359cf9db); sender opens the symlink-free path.


Imported from beads archie-core-jkmu · GitHub #647 · type task · priority P3 · created 2026-08-24 · closed 2026-10-25

internal/tools/builtin/confinement.go ResolveReadable applies exactly the read tool's policy (resolvePath + isReadConfined), which is purely lexical: filepath.Abs/Rel, never EvalSymlinks. A symlink inside the workspace pointing at /etc/shadow passes the check, and the telegram sender then opens att.Path with no confinement check of its own, in a different goroutine after the turn. There is also a real TOCTOU window -- prepare stats/opens/closes, SendMedia re-stats and re-opens later. The policy is unchanged from the read tool, so this is not a new hole; what changed is the consequence. The read tool caps at 5MB into the operator's own context; send_file ships up to 50MB OUT to a chat. The shell tool has never been confined either, so a model that wants the bytes already has them. Decide: either resolve symlinks in ResolveReadable (which changes read-tool behaviour too, and may break legitimate symlinked workspaces), or document the caveat explicitly and stop claiming 'sending cannot reach what reading cannot' without it. Found by adversarial review of 9a45fbb. ## Acceptance Criteria Either the symlink case is closed at the resolver, or the limitation is written down where the claim is made (confinement.go doc comment and sendfile package doc). ### Close reason ResolveReadable now follows symlinks and re-checks the real path (359cf9db); sender opens the symlink-free path. --- _Imported from beads `archie-core-jkmu` · GitHub #647 · type task · priority P3 · created 2026-08-24 · closed 2026-10-25_
sam added the lowtask labels 2026-10-27 13:40:14 +00:00
sam self-assigned this 2026-10-27 13:40:14 +00:00
sam closed this issue 2026-10-27 13:40:14 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1398