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

MGS2003: env vars stripped from child process

The sandbox replaced a child process's inherited environment with a curated allowlist and one or more variables were dropped.

[MGS2003] env vars stripped from child process by sandbox
  cmd=go stripped_count=14

Why

The default allowlist is intentionally small: HOME, PATH, USER, locale and terminal vars, plus the MAGUS_* daemon coordination vars. Everything else is stripped so that a compromised spell cannot exfiltrate AWS_ACCESS_KEY_ID, GITHUB_TOKEN, VAULT_TOKEN, OP_SESSION_*, NPM_TOKEN, ANTHROPIC_API_KEY, and similar.

The warning is informational, not an error. The build may have succeeded; this message exists so you can spot when a tool's behavior changes because a variable it expected is no longer present.

Resolution

If a tool depends on a non-secret variable being inherited (a Go build that needs GOPATH, an npm build that needs NPM_CONFIG_CACHE, mise shims that need MISE_*), add it to the passthrough list:

sandbox:
  env:
    passthrough:
      - GOPATH
      - GOCACHE
      - "MISE_*"

The * is a suffix wildcard: MISE_* matches every name starting with MISE_. It is intentionally not full glob syntax.

If a tool depends on a secret-bearing variable (GITHUB_TOKEN, etc.), think carefully before granting it. The sandbox exists to keep those out of subprocesses. If the tool genuinely needs the token, consider passing it via a file path the spell reads explicitly rather than re-broadcasting it through the environment.

MGS2003sandboxsecurityenvironmentpassthroughsecretssubprocess
Last updated (a170f9b2)
Earlier changes on this page (1)

Full history ↗ · Blame source ↗

Glossary

Spell

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

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. See cache.

Sandbox

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

Daemon

The background magus host that owns shared state such as services and the warm knowledge graph. See daemon.

CI

An ordinary magusfile-defined target you compose yourself with magus\needs - magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Conventions

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