Skip to content

security(sandbox): ambient re-entrancy markers can disable isolation #727

Closed

Description

@PierrunoYT

Summary

Zero trusts the inherited ZERO_SANDBOXED=1 and non-empty ZERO_SANDBOX_BACKEND environment variables as proof that the current process is already sandboxed. These values are user-controlled when Zero starts outside a sandbox.

Policy evaluation can auto-allow an ordinary shell request because the configured engine reports a native backend, while command planning independently sees the forged re-entrancy markers and emits a direct, unwrapped command plan.

Affected code

  • internal/sandbox/types.go:24-31 reads both markers from the ambient environment.
  • internal/sandbox/engine.go:222-248 and 406-412 allow ordinary shell commands based on configured backend capability.
  • internal/sandbox/runner.go:130-170 changes command planning to pass-through/direct execution when the markers are present.
  • internal/sandbox/reentrancy_test.go:115-136 confirms that a caller-supplied marker pair triggers pass-through behavior.

Trigger

Start Zero from an otherwise unsandboxed process with both variables set:

ZERO_SANDBOXED=1
ZERO_SANDBOX_BACKEND=<any non-empty value>

Then execute a shell command that is auto-allowed because native sandbox isolation is expected.

Impact

The command can run directly on the host without the filesystem/network isolation that justified auto-allowing it. A process genuinely inside an outer sandbox remains constrained by that sandbox; the defect is false provenance at an unsandboxed process boundary.

Suggested fix

As an immediate mitigation, disable shell auto-allow whenever re-entrancy causes wrapping to be skipped. Longer term, replace ambient marker trust with authenticated in-process launch state or backend-verifiable confinement.

Add a regression test proving forged startup variables cannot combine an auto-allow decision with an unwrapped command plan.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions