magus v0.4.3 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_* server 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_*"

A trailing * makes a prefix pattern: MISE_* matches every name starting with MISE_. The prefix must be at least three characters and end in _, since GO* would also match GOOGLE_APPLICATION_CREDENTIALS; anything else is an error (MGS2004). 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 (a9ff8609)
Earlier changes on this page (3)

Full history ↗ · Blame source ↗

Glossary

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.

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.

Server

The background process a person starts with magus server start. It serves MCP, the console, background jobs and the warm knowledge graph, and adopts nested magus calls into one pool. See server.

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.

Session

An agent host's conversation, by the id the host delivers to its hooks. magus never mints one: a record with no session is unattributed, and the OS user it carries says whose account ran it.

Conventions

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