fix: refuse in-process jobs on tags with a minimum isolation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-10-18 05:58:53 +02:00
co-authored by Claude Opus 5.5
parent 7be262ab96
commit e2f4583ded
4 changed files with 27 additions and 6 deletions
@@ -198,10 +198,19 @@ pub fn worker_allowed_tags(wc: &WorkerConfig, tags: &[String]) -> Vec<String> {
/// 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<String> {
/// 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<String> {
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!(
@@ -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. \
+5 -3
View File
@@ -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));
}
@@ -441,7 +441,7 @@ export const settings: Record<string, Setting[]> = {
key: 'min_job_isolation_by_tag',
fieldType: 'min_job_isolation_by_tag',
description:
'Require a minimum isolation for the jobs of a tag (none &lt; unshare &lt; 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 <code>-</code>. Native-mode and dedicated workers count as none. This guards against a misconfigured worker group, not against a tampered worker. <a href="https://www.windmill.dev/docs/advanced/security_isolation">Learn more</a>',
'Require a minimum isolation for the jobs of a tag (none &lt; unshare &lt; 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 <code>-</code>. Native-mode and dedicated workers count as none, and jobs that run inside the worker process (native languages, <code>//native</code> Bun scripts) fail on a tag with a minimum.This guards against a misconfigured worker group, not against a tampered worker. <a href="https://www.windmill.dev/docs/advanced/security_isolation">Learn more</a>',
storage: 'setting'
},
{