feat(sandbox): add the in-sandbox agent and the image bundle it ships in - #390
Open
ItamarZand88 wants to merge 1 commit into
Open
feat(sandbox): add the in-sandbox agent and the image bundle it ships in#390ItamarZand88 wants to merge 1 commit into
ItamarZand88 wants to merge 1 commit into
Conversation
Greptile SummaryThe PR adds the in-sandbox execution agent, shared process-output framing, and the image bundle used to ship the agent.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| crates/alien-sandbox-agent/src/server.rs | Defines the agent HTTP protocol and consistently authorizes protected exec and file operations before performing work. |
| crates/alien-sandbox-agent/src/peer.rs | Attributes local transport connections to socket owners and fails closed when a local connection cannot be attributed. |
| crates/alien-sandbox-agent/src/confine.rs | Implements Linux kernel-backed path confinement for sandbox file operations. |
| crates/alien-core/src/sandbox_process.rs | Centralizes bounded process-output streaming, terminal framing, deadline enforcement, and process-group cleanup. |
| crates/alien-build/src/sandbox_bundle.rs | Renders and archives the sandbox image bundle while validating base-image references at the rendering boundary. |
Sequence Diagram
sequenceDiagram
participant Caller
participant Agent
participant Auth as Authorization
participant Kernel as Kernel confinement
participant Child as Sandboxed process
Caller->>Agent: exec or file request
Agent->>Auth: Verify capability or transport peer
Auth-->>Agent: Authorized
Agent->>Kernel: Resolve path beneath session root
Kernel-->>Agent: Confined descriptor/path
Agent->>Child: Spawn as unprivileged identity
Child-->>Agent: Sequenced stdout/stderr frames
Agent-->>Caller: NDJSON stream and terminal frame
Reviews (21): Last reviewed commit: "feat(sandbox): add the in-sandbox agent ..." | Re-trigger Greptile
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 06:55
8f2beff to
7f2f487
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 07:37
7f2f487 to
6510139
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 07:50
6510139 to
39a3fd4
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 08:59
39a3fd4 to
7d0e0a4
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 09:10
7d0e0a4 to
33e13f4
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 12:11
33e13f4 to
6c36ed2
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 13:19
6c36ed2 to
f8a4255
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
2 times, most recently
from
August 11, 2026 16:53
853d4f1 to
182f60b
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
2 times, most recently
from
August 11, 2026 17:28
25bba81 to
af8945f
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 18:40
af8945f to
9d6a588
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 18:49
9d6a588 to
eab73e0
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 19:16
eab73e0 to
a15e370
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
2 times, most recently
from
August 11, 2026 19:49
c2771f2 to
945be88
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 20:08
945be88 to
0b154ba
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
2 times, most recently
from
August 11, 2026 21:26
b59c8b0 to
a3397cd
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 22:16
a3397cd to
e89f04e
Compare
ItamarZand88
force-pushed
the
itamar/alien-75-sandbox-2-agent
branch
from
August 11, 2026 22:24
e89f04e to
76a1e5f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the agent that runs inside a sandbox and executes a caller's code, plus the image bundle it ships in. Layer 1 added the
Sandboxresource type; this adds the process that actually runs something inside one.When a caller asks a sandbox to run a command:
This turns the sandbox from a resource you can declare into one you can run code in.
What I did
The agent is a small HTTP server that ships inside the image. It runs as root so it can drop to an unprivileged user before every spawn; inside a MicroVM that drop sits behind hardware virtualisation, which is the tenant boundary.
Two decisions are worth pointing at:
openat2, not a resolver. Resolving a path and then opening it by name leaves every check in a race window, and the code being confined runs in the same guest and can drive both sides of it.RESOLVE_BENEATH | RESOLVE_NO_SYMLINKSmakes resolution and open one operation. This removed the hand-written component walk, the canonicalisation, and the containment check rather than adding a fourth guard next to them.spawnandspawn_sandboxedare two functions, not a flag. One inherits the environment for our own helper processes; the other clears it. The agent's environment names its own port and session, so handing it to a caller's code hands over a map to the API running it.Files touched
crates/alien-sandbox-agent/— the agent: HTTP surface, exec, file transfer, path confinement, privilege drop, PID-namespace support for runtimes that grant it.crates/alien-core/src/sandbox_process.rs— process framing, shared with the GCP launcher path.crates/alien-build/src/sandbox_bundle.rs— the image bundle and its Dockerfile.crates/alien-bindings/src/error.rs— the error variants the agent's callers see.How I tested
openat2path, and it caught a traversal on write returning 500 instead of 400 that macOS could not have surfaced...traversal and an absolute path are all refused. The control arm reads the same symlink successfully without confinement, so the refusals are the code working rather than a broken fixture.protected_hardlinkschecked on the actual MicroVM base image, as the sandbox uid, with a control arm.cargo checkforalien-buildandalien-bindingsunder their individual feature combinations, not just the workspace build.Security review of this diff, since it runs untrusted code:
setsidchild still escapes, which needs a cgroup and is called out in the module docs.no_new_privsis set after the drop.protected_hardlinksbounds it to files the caller could already write.Nothing turned up.