{"record":{"id":"a8610f41a9a8dce5","repo":"jdx/mise","slug":"failed-to-apply-landlock-restrictions-status","errorCode":null,"errorMessage":"failed to apply landlock restrictions: {status:?}","messagePattern":"failed to apply landlock restrictions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sandbox/landlock.rs","lineNumber":153,"sourceCode":"        // allow_write paths are implicitly readable\n        for path in &config.allow_write {\n            ruleset = add_path_rule(ruleset, path, read_access)?;\n        }\n    } else if deny_write {\n        // Only writes restricted — allow read everywhere, deny write except allowed paths\n        ruleset = add_read_rule(ruleset, \"/\", read_access)?;\n        ruleset = add_read_rule(ruleset, \"/tmp\", full_access)?;\n        ruleset = add_read_rule(ruleset, \"/dev\", full_access)?;\n        for path in &config.allow_write {\n            ruleset = add_path_rule(ruleset, path, full_access)?;\n        }\n    }\n\n    let status = ruleset\n        .restrict_self()\n        .map_err(|e| eyre!(\"failed to apply landlock restrictions: {e}\"))?;\n    if status.ruleset == RulesetStatus::NotEnforced || !status.no_new_privs {\n        eyre::bail!(\"failed to apply landlock restrictions: {status:?}\");\n    }\n\n    Ok(())\n}\n","sourceCodeStart":135,"sourceCodeEnd":158,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/sandbox/landlock.rs#L135-L158","documentation":"After building Landlock rules for sandbox read/write restrictions and calling restrict_self, mise verifies enforcement: status.ruleset must not be RulesetStatus::NotEnforced and the no_new_privs flag must be set. If the kernel silently did not enforce the ruleset (kernel without Landlock, Landlock LSM disabled at boot) or prctl(PR_SET_NO_NEW_PRIVS) failed, mise aborts rather than continue under a false sense of sandboxing. Note restrict_self's own error produces a different message; this one covers 'succeeded but not enforced'.","triggerScenarios":"Running a mise command or task with sandbox restrictions (--deny-read/--deny-write or task sandbox settings) on a kernel older than 5.13, a kernel booted without the landlock LSM in the lsm= list, or inside a container whose seccomp policy blocks the landlock_create_ruleset/landlock_add_rule/landlock_restrict_self syscalls so the ruleset lands in NotEnforced state.","commonSituations":"CI containers (Docker's default seccomp profile on older engines blocks landlock syscalls), older Debian/Ubuntu LTS kernels, WSL2 kernels without Landlock, minimal VM images compiled without CONFIG_SECURITY_LANDLOCK, hosts that boot with a restrictive lsm= kernel parameter.","solutions":["If in a container, run on a runtime/seccomp profile that allows the landlock_* syscalls (recent Docker/containerd defaults do), or supply a permissive profile for the job.","Enable the Landlock LSM: boot with lsm=...,landlock (and ensure the kernel is built with CONFIG_SECURITY_LANDLOCK).","Upgrade to a kernel >= 5.13 (>= 5.19 for full path-beneath features).","If sandboxing is not required for this run, drop the --deny-read/--deny-write flags (or task sandbox config) so landlock is not applied."],"exampleFix":"# before: fails in a container blocking landlock syscalls\nmise x --sandbox --deny-write -- npm run build\n# after: allow the syscalls or drop the sandbox for this step\ndocker run --security-opt seccomp=landlock-profile.json ... mise x --sandbox --deny-write -- npm run build\n# or\nmise x -- npm run build","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# fail fast before running sandboxed commands on hosts without working landlock\nset -e\nkver=$(uname -r | cut -d. -f1-2)\nawk -v v=\"$kver\" 'BEGIN{split(v,a,\".\"); exit !(a[1]>5 || (a[1]==5 && a[2]>=13))}' || { echo 'kernel lacks landlock' >&2; exit 1; }\ngrep -q landlock /sys/kernel/security/lsm 2>/dev/null || grep -q landlock /proc/cmdline || { echo 'landlock LSM not enabled' >&2; exit 1; }\nmise x --sandbox --deny-write -- \"$@\"","typeGuard":null,"tryCatchPattern":"Run the sandboxed command; on failure containing 'failed to apply landlock restrictions', fall back to running the same command without --deny-read/--deny-write and flag the job as unsandboxed (do not silently retry sandboxed).","preventionTips":["Pin CI images to kernels/runtimes that permit landlock syscalls.","Keep sandboxed and unsandboxed task variants so a host without landlock can still run the work.","Treat this error as a security failure, not a flake: never downgrade to ignoring it by default."],"tags":["mise","sandbox","landlock","linux","kernel","security","containers"],"backgroundTag":"landlock-unsupported-kernel","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}