Repository navigation
fix: resolve a viewer app's undeclared runnable with the caller's rls - #12877
rubenfiszel wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying windmill with
|
| Latest commit: |
dce4c8e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e0bb6414.windmill.pages.dev |
| Branch Preview URL: | https://ruben-win-2889-resolve-calle.windmill.pages.dev |
|
/review |
|
Claude finished @rubenfiszel's task in 55s —— View job Good to merge Review summaryI found no blocking issues and no nits worth raising. The fix is small and does what the description says: when the caller named the runnable, What I checked
Behaviour change worth knowing (not a defect)A Viewer app that calls a AGENTS.md complianceI found no violations. The change stays inside the touched modules, the comments explain why the branch exists rather than restating the code, and no EE companion change is needed. Test coverageThis is a backend change, and the new integration test
The test doesn't cover the editor-preview path or the declared-runnable path (which should still resolve with the root DB). Existing suites ( Manual check: the author already ran it on a live instance. One more check worth doing before merge: open an existing Viewer app as a non-admin member, where every component references a runnable declared in its deployed policy, including some the member can't read directly. Every component should still run. A 401 there would mean the declared path wrongly went through |
Codex ReviewGood to merge Test coverageThe new API integration test covers denied and permitted undeclared paths for both scripts and flows as an operator. It does not cover editor preview, app-scoped tokens, or preservation of policy-declared access. I did not rerun the Rust tests or live checks because the configured Postgres was unavailable. The passing suites and live results in the PR description are author-reported. Manually preview a component as a non-admin co-editor: unreadable script and flow paths should return 401, while readable paths should queue successfully. Also confirm a deployed app can still run a policy-declared runnable the viewer cannot read directly. |
|
/pi |
|
/review |
|
✅ Review round clean @ dce4c8e — Codex and Claude: Good to merge; Pi ran twice but produced an empty final message (no verdict). Left in draft: changes an authorization path, wants a human look before ready. |
Summary
In a Viewer-mode app,
POST /api/w/{w}/apps_u/execute_component/{app}accepts ascript/<path>orflow/<path>that the app's policy does not declare, and runs it as the caller. The runnable was looked up through the root database handle, so row-level security never applied: any member who could open one Viewer app (an operator, or a token scoped toapps:run:<app>) could run, and read the results of, scripts and flows they have no read access to (other users'u/paths, folders they are not in)./jobs/run/palready refuses these.The handler now resolves a caller-named path (
caller_named_path: an undeclared path in a Viewer app, or any path in editor preview) through the caller's user DB, so a path the caller cannot read is refused exactly as/jobs/run/prefuses it (401 "not authorized to access this script/flow"). Policy-declared runnables keep resolving through the root DB (RunOrigin::Deployed): the publisher vouched for them at deploy time.Changes
windmill-common/src/jobs.rs: newrunnable_ref_to_payload_with_rls, which takes anOption<UserDbWithAuthed>and hands it toscript_path_to_payload/get_latest_flow_version_info_for_path.runnable_ref_to_payloadkeeps its signature and delegates withNone, so the deployed-handler callers (error/success/recovery handlers, including the EE ones, variable expiration, post-fork script) are untouched and no EE companion PR is needed.windmill-api/src/apps.rs(execute_component): when the caller named the path, buildUserDbWithAuthedfrom the handler's existinguser_dband the caller, as the/jobs/run/phandlers do.backend/tests/app_viewer_named_path_rls.rs: an operator calling an undeclaredscript/f/restricted/xandflow/f/restricted/flthrough a Viewer app gets a 401; the same operator still runs a script and a flow in a folder they can read.Behaviour note: editor preview also takes the caller-named branch, so a non-admin co-editor previewing a component that references a script they cannot read now gets the same refusal they would get from
/jobs/run/p. Admins are unaffected (RLS bypass).Test plan
cargo test --features quickjs --test app_viewer_named_path_rlspasses; with the user DB dropped (passingNone) it fails at the restricted script.hub_named_path,app_preview_auth,app_guest_execution_mode,app_anonymous_execution_mode,app_publisher_permit,app_ctx_inputs,app_run_mode_lock_strip,end_user_email,reserved_control_args.script/f/restricted…/xnow returns 401 (same message as/jobs/run/p), a readablef/shared…/xqueues a job (200), and an admin still runs the restricted path through the app.Left in draft: changes an authorization path, wants a human look before ready.
🤖 Generated with Claude Code
Summary by cubic
Fixes a privilege-escalation hole in Viewer-mode apps: an undeclared
script/<path>orflow/<path>was resolved through the root database, so row-level security never applied and any operator (or token scoped toapps:run:<app>) could run, and read the results of, scripts and flows they have no read access to. Caller-named paths now resolve through the caller's user DB, so a path the caller cannot read is refused exactly as/jobs/run/prefuses it (401 "not authorized to access this script/flow").Written for commit dce4c8e. Summary will update on new commits.