Egress policies
Every outbound connection from a sandbox passes its egress policy. The host enforces the policy in its kernel with
nftables, outside the sandbox, so code running in the sandbox cannot change it. Every connection, allowed or blocked,
is recorded as an egress.connection event in the audit trail.
The built-in deny-list
Section titled “The built-in deny-list”These destinations are blocked for every sandbox, whatever its policy says:
- Private address ranges from RFC 1918:
10.0.0.0/8,172.16.0.0/12and192.168.0.0/16 - Link-local addresses,
169.254.0.0/16, which include the cloud metadata endpoint169.254.169.254 - The host the sandbox runs on
- Known cryptocurrency mining pools and stratum ports
30 mining pool hostnames
pool.minexmr.com, xmr.pool.minergate.com, pool.supportxmr.com, xmrpool.eu, pool.hashvault.pro, monerohash.com, moneroocean.stream, gulf.moneroocean.stream, nanopool.org, xmr-eu1.nanopool.org, xmr-us-east1.nanopool.org, 2miners.com, xmr.2miners.com, ethermine.org, flypool.org, f2pool.com, antpool.com, viabtc.com, slushpool.com, braiins.com, herominers.com, c3pool.com, mineXMR.com, kryptex.com, unmineable.com, zergpool.com, zpool.ca, prohashing.com, miningpoolhub.com, nicehash.com
Stratum ports, blocked for every destination:
3333, 3334, 4444, 5555, 7777, 8888, 9999, 14444, 14433, 45700.
The stratum ports are blocked for every destination, not only for mining pools. A sandbox cannot reach a service on one of those ports anywhere on the internet.
A policy has one of two modes:
denylist: everything is allowed except the built-in deny-list and the rules you add.allowlist: only the destinations in your rules are allowed. The built-in deny-list still applies.
A sandbox created without egress_policy_id has only the built-in deny-list.
A rule names exactly one of host or cidr, and optionally ports. An empty or missing ports means every port. A
policy can have up to 200 rules.
| Field | Example | Matches |
|---|---|---|
host | api.github.com | Connections to the addresses that name resolves to |
cidr | 140.82.112.0/20 | Connections to any address in the range |
ports | [443] | Only those destination ports |
The host enforces rules by address and port. It resolves each host rule’s name when it applies the policy and
again every few minutes, and matches connections against those addresses. The TLS server name (SNI) of a connection
is recorded in its audit event, but it does not decide whether the connection passes. A service behind a CDN can
answer the sandbox with addresses the host did not get; if a destination you allowed is blocked, add a cidr rule
for its range. See How host rules match.
List each hostname. The API accepts a wildcard rule such as *.pypi.org, but hosts refuse a policy that contains
one today, and a sandbox created with that policy fails.
Create a policy and use it
Section titled “Create a policy and use it”This allow-list lets a sandbox install Python packages and call the GitHub API, and nothing else:
curl https://api.wardcase.com/v1/egress-policies \-H "Authorization: Bearer $VIVARIUM_API_KEY" \-H "Content-Type: application/json" \-d '{ "name": "python-packages", "mode": "allowlist", "rules": [ { "host": "pypi.org", "ports": [443] }, { "host": "files.pythonhosted.org", "ports": [443] }, { "host": "api.github.com", "ports": [443] } ]}'The response has the policy’s id. Pass it when you create a sandbox:
const sbx = await vv.sandboxes.create({image: "python",region: "eu-west",egressPolicyId: policy.id,});sbx = vv.sandboxes.create(image="python", region="eu-west", egress_policy_id=policy_id)Change or delete a policy
Section titled “Change or delete a policy”PUT /v1/egress-policies/{id} replaces the policy’s name, mode and rules. Running sandboxes that use the policy receive
the new rules, and the change is recorded as policy.updated.
DELETE /v1/egress-policies/{id} removes a policy. It can return conflict (409) while sandboxes still use it.
See what was blocked
Section titled “See what was blocked”List a sandbox’s egress events and look at action and rule:
curl "https://api.wardcase.com/v1/sandboxes/sbx_4f9k2m8q1z7x3c5v/audit?type=egress.connection" \-H "Authorization: Bearer $VIVARIUM_API_KEY"action is allow or block. rule says which part of the policy decided: builtin for the built-in deny-list,
policy for one of your rules, and default for the mode’s default.