diff --git a/backend/windmill-common/src/min_job_isolation.rs b/backend/windmill-common/src/min_job_isolation.rs index 4dc9c2a98e..cb3cfa6b72 100644 --- a/backend/windmill-common/src/min_job_isolation.rs +++ b/backend/windmill-common/src/min_job_isolation.rs @@ -198,10 +198,19 @@ pub fn worker_allowed_tags(wc: &WorkerConfig, tags: &[String]) -> Vec { /// Why this worker must not run a job with `tag`, if it must not. Pulls already leave refused /// tags out; this catches the jobs handed to a worker directly, like a same-worker flow's steps, -/// which cannot be left for another worker and so fail. -pub fn worker_refusal(wc: &WorkerConfig, tag: &str) -> Option { +/// which cannot be left for another worker and so fail. A job that runs `in_process` (a native +/// language, a `//native` Bun script) gets no sandbox on any worker, so it counts as `None`. +pub fn worker_refusal(wc: &WorkerConfig, tag: &str, in_process: bool) -> Option { let mins = MIN_JOB_ISOLATION_BY_TAG.load(); let min = min_for_tag(tag, &mins)?; + if in_process { + return (min > IsolationLevel::None).then(|| { + format!( + "Tag {tag} requires job isolation {} but this job runs inside the worker process, without isolation", + min.as_str() + ) + }); + } let own = worker_job_isolation(wc); (min > own).then(|| { format!( diff --git a/backend/windmill-worker/src/bun_executor.rs b/backend/windmill-worker/src/bun_executor.rs index 6da968e422..50dfa14a5c 100644 --- a/backend/windmill-worker/src/bun_executor.rs +++ b/backend/windmill-worker/src/bun_executor.rs @@ -2318,6 +2318,16 @@ pub async fn handle_bun_job( None }; + if annotation.native { + if let Some(refusal) = windmill_common::min_job_isolation::worker_refusal( + &windmill_common::worker::WORKER_CONFIG.load(), + &job.tag, + true, + ) { + return Err(error::Error::ExecutionErr(refusal)); + } + } + if annotation.sandbox && NSJAIL_AVAILABLE.is_none() { return Err(error::Error::ExecutionErr( "Script has //sandbox annotation but nsjail is not available on this worker. \ diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 3e97802318..ddd1869580 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -4864,9 +4864,11 @@ pub async fn handle_queued_job( } } - if let Some(refusal) = - windmill_common::min_job_isolation::worker_refusal(&WORKER_CONFIG.load(), &job.tag) - { + if let Some(refusal) = windmill_common::min_job_isolation::worker_refusal( + &WORKER_CONFIG.load(), + &job.tag, + job.script_lang.is_some_and(|lang| lang.is_native()), + ) { return Err(Error::ExecutionErr(refusal)); } diff --git a/frontend/src/lib/components/instanceSettings.ts b/frontend/src/lib/components/instanceSettings.ts index 0feef0a243..bc97b7ea6d 100644 --- a/frontend/src/lib/components/instanceSettings.ts +++ b/frontend/src/lib/components/instanceSettings.ts @@ -441,7 +441,7 @@ export const settings: Record = { key: 'min_job_isolation_by_tag', fieldType: 'min_job_isolation_by_tag', description: - 'Require a minimum isolation for the jobs of a tag (none < unshare < nsjail). A worker whose isolation is below a tag\'s minimum pulls no jobs for that tag: they stay queued until a sufficiently isolated worker picks them up. A minimum also covers the tags derived from it (per-workspace, fork and dev workspace tags): any tag starting with the tag followed by -. Native-mode and dedicated workers count as none. This guards against a misconfigured worker group, not against a tampered worker. Learn more', + 'Require a minimum isolation for the jobs of a tag (none < unshare < nsjail). A worker whose isolation is below a tag\'s minimum pulls no jobs for that tag: they stay queued until a sufficiently isolated worker picks them up. A minimum also covers the tags derived from it (per-workspace, fork and dev workspace tags): any tag starting with the tag followed by -. Native-mode and dedicated workers count as none, and jobs that run inside the worker process (native languages, //native Bun scripts) fail on a tag with a minimum.This guards against a misconfigured worker group, not against a tampered worker. Learn more', storage: 'setting' }, {