fix: apply token path scope to apps that depend on a runnable

Draft
RU
3d ago
+64-1

Summary

GET /api/w/{workspace}/apps/list_paths_from_workspace_runnable/{runnable_kind}/{path} returned the paths of every app that depends on a script or flow without applying the token's path scope. A token restricted with apps:read:<prefix> received app paths outside that prefix, even though apps/get for those paths returns 403. RLS still limited results to apps the token owner can read, so only out-of-scope paths leaked.

Changes

  • list_paths_from_workspace_runnable (backend/windmill-api/src/apps.rs) filters its rows through build_scope_path_predicate(&authed, "apps", "read"), as list_search_apps already does. Unscoped tokens and sessions are unaffected. The endpoint is not paginated, so filtering after the fetch reveals nothing through page sizes.
  • Regression test backend/tests/app_runnable_paths_scope.rs: an unscoped token sees both dependent apps, an apps:read:u/test-user/* token sees only the one in scope. It fails without the fix.

Out of scope, noted for follow-up: the scripts and flows variants of list_paths_from_workspace_runnable (and list_paths_linking_agent) don't filter their returned paths by the token's path scope either.

Test plan

  • cargo test --features quickjs --test app_runnable_paths_scope passes, and fails with the handler change reverted
  • On the running dev instance: two apps depending on u/admin/s in f/allowed and f/other; an unscoped token gets ["f/allowed/app1","f/other/app2"], an apps:read:f/allowed/* token gets ["f/allowed/app1"]

Left in draft: touches a token-scope (auth) path, wants a human look before ready.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes GET /apps/list_paths_from_workspace_runnable so tokens restricted with apps:read:<prefix> no longer receive app paths outside that prefix. Previously the endpoint returned out-of-scope paths even though apps/get on the same paths returns 403; RLS still limited results to apps the token owner can read.

  • Filters returned rows through build_scope_path_predicate, matching what list_search_apps already does.
  • Adds a regression test covering both an unscoped token (sees all dependent apps) and an apps:read:u/test-user/* token (sees only in-scope apps).
  • The scripts and flows variants of this endpoint, and list_paths_linking_agent, still don't filter by token path scope; noted for follow-up.