{"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":200,"sourceCode":"        for path in &config.allow_write {\n            ruleset = add_path_rule(ruleset, path, full_access)?;\n        }\n    }\n\n    // The ruleset is installed before the target's initial exec. Permit that\n    // exact executable while denying later execve/execveat calls for every\n    // other file (including Kernel.exec from evaluated tap Ruby).\n    if config.deny_process\n        && let Some(program) = initial_program\n    {\n        ruleset = add_path_rule(ruleset, program, execute_access)?;\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":182,"sourceCodeEnd":205,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/sandbox/landlock.rs#L182-L205","documentation":"`apply_landlock` applies a Linux Landlock sandbox via `ruleset.restrict_self()`. After the call, it verifies that Landlock is actually enforced (`RulesetStatus::NotEnforced` means the kernel ignored the rules) and that `no_new_privs` is set; otherwise it bails, because silently running unsandboxed would be unsafe.","triggerScenarios":"Running a sandboxed command on a Linux kernel without Landlock support (< 5.13) or with the LSM disabled; running in a container that filters the landlock syscalls; a seccomp/LSA profile blocking `prctl(PR_SET_NO_NEW_PRIVS)`.","commonSituations":"Docker containers with older base kernels or restricted LSMs; WSL1; hardened environments where no_new_privs is stripped; `mise x --sandbox` style commands inside CI images lacking Landlock.","solutions":["Run on a kernel >= 5.13 with the Landlock LSM enabled (`lsm=landlock,...` in kernel cmdline).","Remove `--deny-read`/`--deny-write`/`--deny-process` flags if the environment cannot support Landlock.","Run the command outside the restrictive container/VM, or ask the platform to permit landlock_create_ruleset/restrict_self and PR_SET_NO_NEW_PRIVS."],"exampleFix":"// before (fails in old container)\nmise x --deny-write ./target:mise-sandbox -- make test\n// after\nmise x -- make test  # without landlock-requiring flags, or upgrade host kernel","handlingStrategy":"fallback","validationCode":"uname -r  # require >= 5.13; check /sys/kernel/security/lsm for landlock","typeGuard":null,"tryCatchPattern":"try {\n  await $`mise x --deny-write -- <cmd>`;\n} catch (e) {\n  if (String(e).includes('failed to apply landlock'))\n    console.error('Kernel/LSM lacks Landlock; rerun without sandbox flags');\n  throw e;\n}","preventionTips":["Verify kernel >= 5.13 and landlock in the LSM list before using --deny-read/--deny-write.","Avoid sandbox flags inside containers known to strip Landlock/no_new_privs."],"tags":["sandbox","linux","landlock","kernel"],"backgroundTag":"unsupported-platform","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}