diff --git a/internal/tools/edit.go b/internal/tools/edit.go index f7370066..a08c5b44 100644 --- a/internal/tools/edit.go +++ b/internal/tools/edit.go @@ -170,7 +170,7 @@ func (t *EditTool) Execute(ctx context.Context, args map[string]any) *Result { if workspace == "" { workspace = t.workspace } - allowed := allowedWithTeamWorkspace(ctx, t.allowedPrefixes) + allowed := allowedWriteWithTeamWorkspace(ctx, t.allowedPrefixes) resolved, err := resolvePathWithAllowed(path, workspace, effectiveRestrict(ctx, t.restrict), allowed) if err != nil { return ErrorResult(err.Error()) diff --git a/internal/tools/shell.go b/internal/tools/shell.go index 563661ca..6726ea71 100644 --- a/internal/tools/shell.go +++ b/internal/tools/shell.go @@ -323,7 +323,12 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]any) *Result { if wsBase == "" { wsBase = t.workspace } - allowed := allowedWithTeamWorkspace(ctx, nil) + // Shell is an arbitrary executor — a cross-chat cwd would let the + // command mutate files in another chat's workspace. Enforce the + // stricter write-allowed prefixes (team root excluded) to block + // cross-chat cwd even for "read-only" commands like cat, since we + // cannot prove the shell command will not write. + allowed := allowedWriteWithTeamWorkspace(ctx, nil) resolved, err := resolvePathWithAllowed(wd, wsBase, true, allowed) if err != nil { return ErrorResult(err.Error())