magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
1 min read

MGS2007: exec denied by sandbox

A spell tried to execute a binary whose resolved path is outside every path the policy grants exec on.

[MGS2007] exec denied: /home/user/Downloads/exfil

Why

Exec is a grant of its own: a path the sandbox lets a step read is not thereby a path it may run. The default policy grants exec on the workspace, the private temp dir, the system trees (/usr, /bin, /sbin, /lib*, /opt, /nix/store), each absolute PATH entry other than $HOME and its ancestors, toolchain install roots (GOROOT, rustup, cargo's bin, mise, asdf) and the magus binary. This blocks the attack pattern of dropping a small binary into ~/ and running it.

The binary path is the one exec.LookPath returns, resolved through its symlinks, so an unqualified curl found at /usr/bin/curl is allowed.

Resolution

  • Built-in spells: should never trigger this. If they do, file a bug.

  • A tool you installed somewhere the default does not cover: grant its directory read and exec:

    sandbox:
      allow:
        - path: ~/tools/bin
          mode: rx
    

    ro is not enough: exec is never implied by read.

  • A spell dropping and running a binary: do not extend the allowlist. This is the sandbox working as designed.

MGS2007sandboxsecurityexecpermissionsallowlistbinary
Last updated (a9ff8609)
Earlier changes on this page (1)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. See workspace.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Spell

A language/runtime adapter (e.g. go, md) that maps generic targets onto a toolchain's real commands. See spells.

Sandbox

The restricted filesystem and environment a target runs in, so builds stay reproducible and side-effect-free. See sandbox.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.