Skip to content

Sandboxing & Isolation

Engineer/DeveloperSecurity SpecialistOperations & StrategyDevops

Authored by:

matta
matta
The Red Guild | SEAL

πŸ”‘ Key Takeaway

  • Assume untrusted execution can fail or be compromised, then design containment by default.
  • Apply layered controls across identity, runtime, filesystem, network, and resources.
  • Increase isolation depth as risk increases (container hardening β†’ sandboxed containers β†’ microVM/VM).

This section is the DevSecOps guide for running untrusted or semi-trusted execution safely: CI jobs, pull request validation, build scripts, plugins, package hooks, internal automation, and AI agents (as one automation category among many).

The core objective is simple: assume compromise can happen, then contain blast radius by design.

What to protect (threat model quickstart)

Treat sandboxing decisions as a threat-modeling exercise across four dimensions:

DimensionQuestions to answer
AssetsWhat can be stolen or modified? (source code, signing keys, CI secrets, deployment credentials, artifacts, production APIs)
Entry pointsWhat can trigger execution? (fork PRs, dependencies, build scripts, test fixtures, webhooks, external APIs)
PrivilegesWhat authority does runtime hold? (filesystem write, network egress, cloud IAM, package publish, deployment rights)
ImpactWhat is worst-case outcome? (secret exfiltration, artifact tampering, lateral movement, production change, financial loss)

Default assumption: code from external contributors, third-party actions, and newly introduced dependencies are untrusted until verified.

Decision tree: choose isolation depth

Use this practical decision flow before assigning a runtime:

  1. Does the workload process untrusted input or untrusted code?
    • If yes, run in an ephemeral sandbox (container with hardened profile at minimum; microVM/VM for higher assurance).
  2. Can the workload access secrets, signing keys, cloud credentials, or production systems?
    • If yes, enforce stronger isolation boundary, short-lived credentials, and explicit approval gates.
  3. Is outbound network required?
    • If no, deny all egress.
    • If yes, allowlist destinations and force traffic through inspection/proxy controls.
  4. Can it modify persistent state (artifact repo, registry, infra, chain, database)?
    • If yes, require policy checks + attestation + auditable identity before execution.
  5. Is this multi-tenant shared runner infrastructure?
    • If yes, isolate per job with ephemeral workers and avoid secret reuse across jobs.

If you answer β€œyes” to multiple high-risk questions, prefer microVM/VM isolation plus strict policy enforcement.

Layered control map (defense in depth)

No single mechanism is sufficient. Apply multiple layers together:

LayerControl objectiveTypical controls
IdentityBind execution to least privilege identityOIDC federation, short-lived tokens, scoped IAM roles
Execution boundaryPrevent host escape / cross-tenant impactseccomp, AppArmor/SELinux, rootless containers, gVisor/Kata/Firecracker
Filesystem & secretsPrevent sensitive data exposureread-only rootfs, isolated workdir, mounted secret scopes, no long-lived credentials
NetworkPrevent exfiltration and lateral movementdefault-deny egress, DNS restrictions, NetworkPolicy, egress proxy
Resource governancePrevent abuse and runaway costCPU/memory/pids/time limits, quotas, job timeout, concurrency caps
Integrity & provenanceDetect tampering and unauthorized changessigned artifacts, provenance attestations, immutable logs, SLSA controls
Policy & responseEnforce and verify continuouslypolicy-as-code gates, runtime audit logs, alerting, incident playbooks

Baseline controls for CI/CD and runners

At minimum, enforce the following:

  • Separate untrusted PR runners from trusted build/deploy runners.
  • Use ephemeral runners (fresh environment per job, no state reuse).
  • Disable or heavily constrain secrets for forked PR jobs.
  • Restrict CI token scopes to least privilege (read by default).
  • Deny outbound network by default; allow only required hosts.
  • Run with syscall and privilege restrictions (seccomp, no privileged mode, no host mounts unless strictly required).
  • Sign and attest release artifacts before publish/deploy.

Start here (section map)

References