Skip to content

deploy/vm: sandboxes can reach cloud instance metadata (169.254.169.254) #357

Closed

Description

@pdettori

Problem

On deploy/vm, sandbox containers can reach cloud instance metadata at 169.254.169.254.

MI1 R8's nftables table (deploy/vm/setup-vm.sh, install_sandbox_firewall) filters only the input hook: traffic addressed to the host itself. Metadata traffic is forwarded through the host, and the forward path is deliberately untouched in S1, because outbound egress is S5's (moca-egress) work. setup-vm.test.sh even asserts that no hook forward chain exists.

On an EC2 host with IMDSv1 enabled, or IMDSv2 with a hop limit of 2 or more, model code in a sandbox can therefore read the instance role's credentials. Those belong to the host, not to any session or user. Other clouds' metadata services are exposed the same way.

Current mitigation (documented, not enforced)

deploy/vm/README.md now says to close this at the platform:

aws ec2 modify-instance-metadata-options --instance-id <id> \
  --http-tokens required --http-put-response-hop-limit 1

With a hop limit of 1, a forwarded container request cannot obtain an IMDSv2 token.

Proposed fix

Add a forward-hook chain to the moca_sandbox table that drops link-local destinations arriving from the sandbox bridge:

chain forward {
  type filter hook forward priority filter; policy accept;
  iifname "moca-sandbox0" ip daddr 169.254.0.0/16 counter drop
  iifname "moca-sandbox0" ip6 daddr fd00:ec2::254 counter drop
}

Update setup-vm.test.sh's "no forward hook" assertion to "the forward hook drops only link-local metadata".

It was not done in #350 because that firewall was verified live on the rig, and a table that fails to load keeps every sandbox down, since the unit is fail-closed through RequiredBy=. So this change needs its own live run: metadata unreachable from a sandbox, outbound internet still working, and the relay attach port still working. If S5's moca-egress lands first and covers this, close this issue in its favour.

Context

Found in the self-review of #350 (MI1 S1). It is recorded as deferred in docs/specs/2026-09-28-moca-multi-user-isolation-design.md §13 ("Blocking cloud instance metadata from sandboxes"). Related to the microVM tier's egress work in #277.

Assisted-By: Claude (Anthropic AI) [email protected]

Activity

  1. added
    bug
    on Sep 29, 2026
  2. added a commit that references this issue on Oct 15, 2026
    ba8bbd1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions