Skip to content
mulga

Security Groups and Egress

How Spinifex enforces AWS security groups as OVN ACLs, blocks outbound SMTP by default, and protects the instance-to-host metadata and the VPC DNS plane.

vpcsecurity-groupsfirewallsmtpimds

Overview

Security groups are stateful firewalls enforced at the OVS datapath level on each hypervisor. Traffic is filtered before it reaches the wire — equivalent to AWS Nitro card enforcement. The VM never sees dropped packets.


Instructions

How Security Groups Work

Each security group maps to an OVN Port Group. When an instance launches, its ENI port is added to the port group(s) for its security groups. ACL rules on the port group control traffic:

  • Default deny: All inbound traffic dropped at priority 900
  • Allow rules: Specific ports/protocols allowed at priority 1000 (overrides deny)
  • Stateful: All allow rules use allow-related — return traffic is automatically permitted

Default Security Group

Every VPC gets a default security group that:

  • Allows all inbound from instances in the same security group
  • Allows all outbound
  • Denies all other inbound

AWS Rule → OVN ACL Translation

AWS Security Group RuleOVN ACL Match
Ingress TCP/22 from 0.0.0.0/0outport == @sg && ip4 && tcp.dst == 22
Ingress TCP/443 from 10.0.0.0/8outport == @sg && ip4 && tcp.dst == 443 && ip4.src == 10.0.0.0/8
Ingress ALL from sg-otheroutport == @sg && ip4 && ip4.src == $sg_other_ip4
Egress TCP/8443 to pl-1a2b3c4dinport == @sg && ip4 && tcp.dst == 8443 && ip4.dst == $spx_pl_1a2b3c4d
Ingress ICMP from anywhereoutport == @sg && ip4 && icmp4
Egress ALL to 0.0.0.0/0inport == @sg && ip4
Default deny inboundoutport == @sg (priority 900, action=drop)

Example: Allow SSH + HTTP

bash
# Create security group
SG=$(aws ec2 create-security-group --group-name web \
  --description "Web servers" --vpc-id $VPC \
  --query GroupId --output text)

# Allow SSH from anywhere
aws ec2 authorize-security-group-ingress --group-id $SG \
  --protocol tcp --port 22 --cidr 0.0.0.0/0

# Allow HTTP from anywhere
aws ec2 authorize-security-group-ingress --group-id $SG \
  --protocol tcp --port 80 --cidr 0.0.0.0/0

# Launch instance with this SG
aws ec2 run-instances --image-id $AMI --instance-type t3.small \
  --subnet-id $SUBNET --security-group-ids $SG --key-name mykey

Rule changes take effect immediately — no instance restart needed.

Platform Default Egress Restrictions (Outbound SMTP)

Like AWS, Spinifex blocks outbound SMTP from instances by default so a compromised guest cannot turn a fresh account into a spam relay. Connections to the mail ports are dropped at the OVS datapath before they reach the wire:

PortProtocolPurpose
25TCPSMTP relay
465TCPSMTP over implicit TLS
587TCPSMTP submission

This is a platform default, not a security-group rule. It is enforced as an OVN egress ACL on every guest's port group at a priority above tenant SG allows, so a tenant cannot open these ports by adding a security-group rule — matching AWS, where lifting the block is an operator action, not a tenant one. Only public destinations are blocked; mail to private ranges (10/8, 172.16/12, 192.168/16, 100.64/10, link-local) is exempt, so an in-VPC or on-prem relay still works. Dropped attempts are logged for abuse triage.

It sits alongside the security-group ACLs and the host firewall (the nft policy that scopes the node's own ports) as a third datapath control — this one applies to guest egress specifically.

Operator controls (cluster-wide, in spinifex.toml):

toml
[network]
# Omit for the default [25, 465, 587]; set [] to disable entirely.
blocked_ports_wan = [25, 465, 587]

# Workaround to let a specific tenant/VPC send mail, until per-account
# exceptions exist: list the VPC IDs to exempt from the block.
egress_block_exempt_vpcs = ["vpc-0abc123..."]

Exempting a VPC removes the block for all guests in that VPC, so scope it narrowly. Add every VPC ID you want exempt to the one list — egress_block_exempt_vpcs = ["vpc-a", "vpc-b", ...]; the match is by VPC ID, so one entry covers every security group in that VPC.

Multi-node clusters: keep the value identical on every node, and restart vpcd

[network] is a cluster-wide setting, but it physically lives in each node's own spinifex.toml, and there is no live distribution of it. Two properties of the current implementation make the operator responsible for consistency:

  • One node writes the ACLs. SG reconcile runs on a single CAS-elected vpcd leader, which programs the shared OVN northbound DB. Whichever node holds the lease is the one whose blocked_ports_wan / egress_block_exempt_vpcs is in force. Leadership moves on restart or crash, so if the node configs disagree, the effective policy changes when the leader changes and the drift pass flaps the ACLs between the two states. Edit the value identically on every node.
  • It is read at vpcd startup, not hot-reloaded. The policy is built once when vpcd starts; editing the TOML does nothing until vpcd restarts. Deploy the config change to all nodes and restart vpcd cluster-wide (take the target down and confirm no spx process survives — a selective single-service restart is not reliable on the shared binary).

This is the current implementation and is deliberately minimal. A future revision will move the exemption into shared cluster state (so a single edit propagates and cannot drift between nodes) and make it a per-account control rather than a per-VPC operator edit; until then, the two rules above are load-bearing.

The Instance-to-Host Plane (Metadata and VPC DNS)

Security groups govern traffic between instances and to the outside. There is a third path they do not touch, and it is the one most easily left exposed: traffic from an instance to the host it runs on.

Every instance reaches two link-local addresses served by the hypervisor:

AddressServicePort
169.254.169.254Instance metadata (IMDS) — cloud-init, instance-role credentialsTCP 80
169.254.169.253VPC DNS resolverUDP/TCP 53

These are not guest addresses and not OVN routed. Each instance's tap has a capture rule on the hypervisor that intercepts any packet addressed to .254 or .253 and delivers it to a per-ENI internal port in the host network namespace (named ime-*). That interception is by destination address only — it does not match the port. A packet to 169.254.169.254:22 is delivered to the host just as readily as one to 169.254.169.254:80.

That matters because host services — SSH, the AWS gateway on 9999, the console on 3000, the DNS server — bind the wildcard address, so they also answer on these link-local addresses. Without a control on the ime-* path, an instance can reach every one of them, with none of the source scoping that protects the same services on the network. A resolver query sent straight to the host's DNS port this way also bypasses the per-instance DNS rate limit.

This plane is invisible to a network firewall

The critical point for anyone securing a deployment: this traffic never crosses the physical NIC. It is intra-host, on the OVS bridge between the instance's tap and the ime-* port. A cloud security group, an upstream firewall, ufw, or any rule written against the WAN interface is not in this path and cannot filter it. The only place to enforce it is on the ime-* interface in the host itself.

How it is protected

Spinifex's host firewall carries a rule that scopes the ime-* path to exactly the two legitimate endpoints and ports — IMDS on .254:80, DNS on .253:53 — and drops everything else. Whether you have that rule depends entirely on whether the host firewall is on:

Install pathHost firewallThis plane
From the ISOonprotected
Binary installer (curl | bash) or setup.shoffexposed
Binary installer with --firewall=ononprotected

The binary installer and setup.sh also arm the firewall when firewalld or ufw is active on the host, so that the Spinifex policy replaces it. A rerun without --firewall keeps the mode that the previous install recorded.

The ISO ships the firewall armed, so ISO deployments are protected out of the box. The binary installer ships it off — deliberately, because it runs on servers that may already have services the installer knows nothing about, and a default-deny policy could cut them off. The consequence is that a binary install left at its default has this plane wide open, and so does every host service on the WAN besides.

If you install any way other than the ISO, turn the host firewall on. At install time:

bash
curl -fsSL https://install.mulgadc.com | bash -s -- --firewall=on
# or, from a source checkout:
sudo /usr/local/share/spinifex/setup.sh --firewall=on

or afterwards, in /etc/spinifex/spinifex.toml, followed by a daemon restart:

toml
[network]
firewall_enabled = true

Before enabling it, check what else the machine is serving — anything listening outside the public port group stops accepting new connections. See Host Firewall for the full port policy and the cluster-formation steps.

Verifying it

On the hypervisor, the ime-* accept should be scoped, not blanket:

bash
sudo nft list chain inet spinifex_filter input | grep ime
# Expect three rules naming 169.254.169.254 tcp dport 80 and 169.254.169.253
# udp/tcp dport 53, and one for the S3 endpoint proxy (meta mark 0x8473),
# not a bare `iifname "ime-*" accept`.

From an instance, the two service ports work and nothing else does:

bash
curl -s -o /dev/null -w '%{http_code}\n' http://169.254.169.254/latest/meta-data/   # 401 (IMDSv2)
dig +short @169.254.169.253 example.com A                                            # resolves
nc -vz 169.254.169.254 22                                                            # must fail

A missing spinifex_filter table means the host firewall is off and this plane is unprotected regardless of the rule above.


Troubleshooting