Skip to content

Opt-in privileged shells via AWS additionalOsCapabilities - #4

Merged
udgover merged 2 commits into
mainfrom
privileged-shells
Jul 1, 2026
Merged

Opt-in privileged shells via AWS additionalOsCapabilities#4
udgover merged 2 commits into
mainfrom
privileged-shells

Conversation

@udgover

@udgover udgover commented Jul 1, 2026

Copy link
Copy Markdown
Owner

What

Adds support for AWS Lambda MicroVM Operating system capabilities — throwaway shells that can mount filesystems, create network namespaces, run eBPF, and nest containers, none of which a root shell can do under the default restricted capability set.

whim --privileged                 # throwaway shell with ALL OS capabilities
whim run --privileged -- mount -t tmpfs none /mnt
whim build ./app --name whim-app --privileged   # bake caps into a custom image

Privilege is opt-in: default images stay minimal-cap and it is never granted implicitly.

How

  • Library: a forward-compatible []Capability (only CapabilityAll = "ALL" is accepted today) threaded through ImageSpec / BuildFromSourceOptions → awsapi → the SDK's additionalOsCapabilities.
  • CLI: a truthful boolean --privileged. whim --privileged / whim run --privileged launch the well-known whim-privileged image — auto-built on first use like whim init, shipping the tooling to use the caps (util-linux, iproute, e2fsprogs), and mutually exclusive with --image.

Correctness & hardening

  • Capabilities are part of the reuse contract. reuseImage compares an existing version's caps (via a new GetMicrovmImageVersion) against the request and refuses a mismatch (ErrCapabilityMismatch) — a privileged build never reuses an unprivileged image or vice versa, and whim --privileged verifies a cached ARN is actually privileged before reuse.
  • Validate before destroy. validateImageSpec (required fields + capabilities + egress) runs before any destructive/AWS action, so an invalid or incomplete spec never costs the caller their image on ForceRebuildImage's delete.
  • Bounded, quiet auto-build. First-use privileged build is bounded by imageBuildTimeout and streams progress to stderr, keeping whim run stdout limited to remote output.
  • whim image rm now prunes the deleted image's config entry.

Validation

  • Unit: capability mapping, both reuse-mismatch directions, dedup set-compare, validate-before-delete (fields/caps/egress), and the cached-privileged decision (reuse / rebuild / refuse). Full go test ./... green; go vet and gofmt clean.
  • Live (us-east-1): an ["ALL"] image reaches CREATED/ACTIVE; a privileged shell performs mount/ip netns/unshare (CapEff 000001ffffffffff) while an identical unprivileged shell is denied (a80425fb); and a non-privileged build over the privileged image is refused.

Out of scope (documented)

Baked/snapshotted Docker daemon, per-capability granularity (AWS supports only ALL), and auto-upsizing disk/memory for nested workloads.

Add support for AWS Lambda MicroVM "Operating system capabilities": build
and launch throwaway shells that can mount filesystems, create network
namespaces, run eBPF, and nest containers — operations a root shell cannot
perform under the default restricted capability set.

Capabilities are modelled in the library as a forward-compatible
[]Capability (only CapabilityAll = "ALL" is accepted today) and threaded
through ImageSpec/BuildFromSourceOptions -> awsapi -> the SDK. The CLI
exposes a truthful boolean:

  - `whim build --privileged`            bake ALL caps into a custom image
  - `whim --privileged` / `whim run --privileged`
        launch the well-known whim-privileged image (tooling: util-linux,
        iproute, e2fsprogs), auto-built on first use like `whim init`,
        mutually exclusive with --image

Capabilities are part of the image reuse contract: reuseImage compares an
existing version's additionalOsCapabilities (via a new GetMicrovmImageVersion)
against the request and refuses a mismatch (ErrCapabilityMismatch), so a
privileged build never reuses an unprivileged image or vice versa, and
`whim --privileged` verifies a cached ARN is actually privileged before reuse.

Hardening and correctness:
  - validateImageSpec (required fields + caps + egress) runs before any
    destructive/AWS action, so an invalid or incomplete spec never costs the
    caller their image on ForceRebuildImage's delete.
  - privileged auto-build is bounded by imageBuildTimeout and streams progress
    to stderr, keeping `whim run` stdout limited to remote output.
  - `whim image rm` now prunes the deleted image's config entry.

Validated live: an ["ALL"] image reaches CREATED/ACTIVE, a privileged shell
performs mount/netns/unshare while an identical unprivileged shell is denied,
and a non-privileged build over the privileged image is refused.
Address errcheck (unchecked Close in read-only source paths) and
staticcheck QF1001 (De Morgan simplifications) in the microvm source
loaders. Bump checkout@v5, setup-go@v6, and golangci-lint-action@v8 to
drop the deprecated Node 20 action runtime.
@udgover
udgover merged commit 28cec34 into main Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

let a user launch a throwaway shell that can actually do privileged kernel-level things (mount, netns, eBPF, nested containers)

1 participant