Skip to content

improvement(execute): enforce workspace permissions on function file exports - #6427

Merged
waleedlatif1 merged 1 commit into
stagingfrom
worktree-fn-execute-workspace-authz
Aug 8, 2026
Merged

improvement(execute): enforce workspace permissions on function file exports#6427
waleedlatif1 merged 1 commit into
stagingfrom
worktree-fn-execute-workspace-authz

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Check the acting user's workspace access before a function execution uses a request-supplied workspaceId
  • Gate workspace file writes in the shared VFS writer so every caller is covered by default
  • Resolve access once per request and thread it through the export path so the added check doesn't re-query per output file

Type of Change

  • Bug fix

Testing

Unit tests added for the new checks; verified they fail without the fix. Full type-check and lint pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…exports

Check the acting user's workspace access before a function execution uses a
request-supplied workspaceId, and gate workspace file writes in the shared VFS
writer so every caller is covered by default.

Access is resolved once per request and threaded through the export path so the
added check does not re-query per output file.
@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR enforces workspace permissions for function output exports and shared VFS writes while reusing request-scoped access results to avoid per-file authorization queries.

  • Checks direct request-supplied workspace access before function execution proceeds.
  • Resolves and verifies workflow-derived workspace write access before export preparation and mutation.
  • Moves write authorization into the shared resource writer so all callers are protected.
  • Adds route and writer tests for non-member and read-only denial paths.

Confidence Score: 5/5

The PR appears safe to merge, with workspace write authorization consistently enforced before export validation and mutation.

The changed execution and shared-writer paths resolve effective workspace access, require write permission, and preserve authorization across batched writes without exposing an unauthorized mutation path.

Important Files Changed

Filename Overview
apps/sim/app/api/function/execute/route.ts Adds request and export-path workspace authorization, threads resolved access through all output branches, and returns explicit denial responses.
apps/sim/lib/copilot/vfs/resource-writer.ts Centralizes workspace write authorization in both target validation and file mutation operations.
apps/sim/lib/copilot/request/tools/files.ts Resolves workspace access once per prepared output batch and safely passes it to the shared writer.
apps/sim/app/api/function/execute/route.test.ts Adds coverage for direct workspace denial, read-only export denial, and workflow-derived workspace denial.
apps/sim/lib/copilot/vfs/resource-writer.test.ts Adds coverage proving unauthorized and read-only users are rejected before file lookup or mutation.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant Execute as Function Execute Route
  participant Authz as Workspace Access Resolver
  participant Sandbox
  participant Writer as Shared VFS Writer
  Caller->>Execute: POST code, workspaceId/workflowId, outputs
  Execute->>Authz: Check direct workspace access
  Authz-->>Execute: WorkspaceAccess
  Execute->>Sandbox: Execute function
  Sandbox-->>Execute: Exported files
  Execute->>Authz: Resolve export workspace write access
  Authz-->>Execute: Writable access or denial
  Execute->>Writer: Write file with resolved access
  Writer->>Authz: Validate reusable access
  Writer-->>Execute: Written file or access denial
Loading

Reviews (1): Last reviewed commit: "improvement(execute): enforce workspace ..." | Re-trigger Greptile

@simstudioai simstudioai deleted a comment from vercel Bot Aug 8, 2026
@simstudioai simstudioai deleted a comment from cursor Bot Aug 8, 2026
@waleedlatif1
waleedlatif1 merged commit 52be28e into staging Aug 8, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-fn-execute-workspace-authz branch August 8, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant