# Enforcement points

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> Ringleader enforces an egress policy outside the workstation, in your cloud's firewall, an edge instance, an edge VM or a network process.


Ringleader enforces an egress policy outside the workstation, in your cloud's firewall, an edge
instance, an edge VM or a network process. The first two are in your cloud, and the last two run on
your computer. Which one depends on the provider and on what the policy names. This page says what
holds a policy on each provider. It also says what a workstation reaches while an Edge is missing,
and what Ringleader checks when you apply a policy.

## Components that enforce a policy

Four things can hold a policy, and each sits outside the workstation:

- **Your cloud's firewall.** On AWS, Azure and GCP, Ringleader compiles the policy into a
  firewall object that your cloud applies to the VM. Those objects match addresses, so your cloud
  holds a `cidr` destination exactly. The egress control grant that writes those objects is on by
  default in the onboarding assets. See [Cloud accounts](https://docs.ringleader.dev/cloud-accounts/).
- **An edge instance.** A VM that Ringleader builds in your cloud account. It reads the name off a
  connection as it passes.
- **A network process.** On hcs, vz and qemu, Ringleader runs one for each workstation, on your
  computer, to carry its traffic.
- **An edge VM.** A small VM that the Ringleader daemon on your computer runs. It runs only when
  an administrator has declared an Edge for hcs, vz or qemu.

A `host` is a name, and a firewall that matches addresses cannot decide on a name. The name
appears on the connection, not in the packet's destination address. Enforcing a name needs
something that reads it off the connection as it passes, which is what an Edge does.
See [Edge management](https://docs.ringleader.dev/security/outbound/edge-management/) for more.

## Enforcement by provider

The provider decides what holds a policy, and whether an Edge is needed:

| Provider | Enforced with no Edge | Needs a declared Edge for | A declared Edge |
|---|---|---|---|
| GCP, Azure | Your cloud's firewall holds `cidr` destinations and the ranges and `privateNetworks` of a deny list. | A `host` destination or deny entry, and `audit`. | An edge instance in your cloud account reads names and holds them on ports 80 and 443. |
| AWS | Your cloud's firewall holds `cidr` allow destinations. | A `host` destination, `audit`, and any deny list entry, because an AWS security group can only allow. | The same. |
| hcs (Windows), vz (Mac), qemu (Linux) | The workstation's own network process holds names and addresses. A `strict` or `audit` policy is accepted when you apply the workstation. | Nothing. | Optional: an edge VM on your computer holds the policy instead. |

An hcs, vz or qemu workstation created before its provider gave each workstation its own address
cannot be served by its own network process. It cannot sit behind an edge VM either. On qemu,
neither can one created before Ringleader could set up the network cards its own Edge needs.
With no Edge, a `bestEffort` one runs unrestricted and reports `NoEdge`. A `strict`, `audit` or
`open` one is held closed. The exception is a vz or hcs workstation under `open`. It keeps its open
network and reports the names in its list as not enforced. Delete it and create it again.

On a cloud, an Integration that injects a credential or inspects a host also needs an Edge,
whatever the workstation's policy.

## Firewall rules that defeat a policy on Google Cloud

The rules Ringleader writes are enough on their own to narrow a workstation. The one thing that can defeat them is a firewall rule of your own, because Google evaluates rules by priority and the lowest number wins:

| Priority | Rule |
|---|---|
| `0`–`899` | Yours, deliberately left free so you can always override Ringleader in your own VPC |
| `900` | the policy's allowances, written by Ringleader |
| `1000` | the policy's default-deny, written by Ringleader |
| `65535` | Google Cloud's own implied allow-all egress, which the deny above exists to beat |

An outbound `allow` rule of yours below `900` therefore wins over the deny. The workstation reaches whatever that rule permits, while Ringleader still reports the policy as enforced, because it checks the rules it wrote and not yours. That is deliberate, so you can always override Ringleader in your own VPC. Know it before you write the first policy.

The network the onboarding creates has no egress rule at all, so a VPC it built is clear. In a VPC you already had, check first:

```bash
gcloud compute firewall-rules list --project <project> --filter='direction=EGRESS' \
  --format='table(name, network.basename(), priority, disabled,
                  targetTags.list():label=TARGET_TAGS,
                  allowed[].map().firewall_rule().list():label=ALLOW)'
```

## Workstation-to-workstation traffic on Google Cloud

A policy also stops workstations reaching each other. If your developers run work that spans several workstations, a policy stops them talking to each other unless you allow it. Name the workstation subnet range among the policy's destinations and they keep talking.

The `allow_internal_traffic` rule of the onboarding module is on by default. It lets workstations accept connections from each other. A policy governs what a workstation may start, so that rule alone is not enough once a policy is in place.

## Network security groups on Azure

Every workstation has two network security groups (NSGs), one on the subnet and one on its network interface. Azure applies both, and traffic must be allowed by both:

| Where | Group | Managed by | Decides |
|---|---|---|---|
| the subnet | the one the module created | you, plus the one SSH rule Ringleader adds | who may reach the workstation |
| the network interface, with a policy | one per egress policy | Ringleader | where the workstation may connect |
| the network interface, without a policy | one shared by those workstations | Ringleader | inbound from outside the virtual network: SSH only, from the addresses in [The SSH rule Ringleader writes](https://docs.ringleader.dev/cloud-accounts/accounts-reachability/#the-ssh-rule-ringleader-writes) |

Three things follow, and all three are about what you put where:

- **Keep your inbound rules on the subnet group.** Apart from its one SSH rule, Ringleader leaves that group alone. On a workstation with a policy, the interface group admits all inbound traffic, so the subnet group alone decides who gets in. On a workstation without one, the interface group admits only SSH from outside the virtual network, even where your subnet group opens another port. So adding a policy to a workstation can let in whatever else your subnet group allows.
- **Do not put your own group on a workstation's network interface.** An interface holds only one. A namespace admin can set `providerConfig.azure.networkInterfaceId` to bring your own interface. If its group has inbound rules, Ringleader replaces that group when it creates the workstation, policy or not, and those rules disappear. Put them on the subnet group instead.
- **Do not add an outbound Deny to the subnet group.** It cannot make a policy tighter, because the interface group already blocks everything the policy does not list. It can only break a policy, by blocking something the policy allows, and that looks like Ringleader ignoring your list.

## Security groups on AWS

With egress control on, the network the onboarding creates has two security groups. One lets nothing out (the inbound-only group) and one lets everything out. A workstation with an egress policy needs the inbound-only group. [Choose the security group for workstations](https://docs.ringleader.dev/guides/onboard-aws/#choose-the-security-group-for-workstations) says which group each workstation gets and what Ringleader refuses.

There are two because of a rule of AWS. A security group can only allow, never deny, and an instance may do anything any of its groups allows. So the group Ringleader builds for a policy can only add to what the instance's other groups permit. Next to a group that lets everything out, a policy restricts nothing. Next to one that lets nothing out, the instance reaches exactly what the policy lists.

For the same reason, an outbound rule of any kind on the inbound-only group undoes every egress policy in the VPC. The group has none on purpose. [Security groups for workstations](https://docs.ringleader.dev/reference/providers/aws-permissions/#security-groups-for-workstations) lists both groups.

## A policy that names a host

What a `host` destination gets on a cloud depends on whether an Edge serves your workstation's
provider and region. The last case costs you the whole policy, not just the names, so read it
before you declare a `host`:

| | `bestEffort` | `strict` | `audit` |
|---|---|---|---|
| **An Edge serves it** | The edge instance enforces the name on ports 80 and 443. | The same. | The edge instance records the connection and enforces no destination. |
| **An Edge is declared for its provider and region, and is not serving it yet** | Held closed, reporting `EgressEnforced: False` with reason `GatewayNotServing`. | The same. | The same. |
| **No Edge is declared** | Unrestricted, reporting `NoEdge`. | Refused when you apply it. A workstation that was admitted and then lost its Edge is held closed. | The same as `strict`. |

<div class="callout callout-warning">
  <p class="callout-title">An unserved bestEffort policy enforces nothing</p>
  <div class="callout-body">
    A <code>bestEffort</code> workstation with no Edge is unrestricted in full, and the <code>NoEdge</code> message names
the provider and region. Ringleader builds a rule set whole or not at all. So one <code>host</code> in the
policy leaves the workstation able to reach any address on any port, including its <code>cidr</code>
destinations. If its Edge was deleted, the workstation keeps the rule set it had while it was
routed, which permits the whole public internet. Its <code>EgressEnforced</code> message says so.
  </div>
</div>


A workstation that was already enforcing an earlier policy keeps that one instead of running
unrestricted, and the message says which. If an edge instance enforced that earlier policy,
keeping it restricts nothing.

A workstation with an injected credential and no egress policy is not held closed. It runs on its
usual network, without the credential, until an edge instance serves it.

## Held-closed workstations

A workstation is held closed while its policy needs an Edge that is not serving it. A `strict`
workstation is never failed for its policy once it is running. It is held closed instead, while
no Edge serves a policy that needs one.

- On a cloud, a held-closed workstation reaches only what it needs to stay managed by Ringleader,
  and the endpoints of the Integrations attached to it. It keeps running, you can still edit it,
  and you can still reach it over SSH.
- On hcs, vz and qemu, a held-closed workstation reaches nothing until its network process or the
  edge VM serves it.

## Deny lists and the open setting

An `open` policy reaches everything except its deny list, and what that costs depends on where the
list is enforced.

On hcs, vz and qemu, what an `open` workstation reaches depends on whether the list needs names
read:

- On vz and hcs, a list of ranges alone leaves the workstation on its open network. Everything
  the list does not name stays reachable over TCP, UDP and ping.
- When the list names a `host`, a vz or hcs workstation runs behind its own network process
  instead, because only a process that reads names can hold a name. It then carries TCP and DNS
  alone, as [Traffic behind an edge instance](https://docs.ringleader.dev/security/outbound/filtering/#traffic-behind-an-edge-instance)
  describes.
- A qemu workstation with an `open` policy always runs behind its network process, with the same
  TCP and DNS limit. [qemu network cards](#qemu-network-cards) says when that restarts it.

A workstation behind a declared edge VM has its whole list enforced by that VM. A vz or hcs
workstation created before its provider gave each workstation its own address cannot run behind
its own network process. It keeps its open network and reports the names in its list as not
enforced. A qemu workstation that cannot run behind its own network process is held closed.

On a cloud, your cloud's firewall or an Edge enforces the list. If the list needs an Edge and the
namespace declares none for the provider, `rl apply` rejects a `strict` or `open` workstation.
While a declared Edge is not serving it yet, the workstation is held closed. A `bestEffort`
workstation is set up either way, and `EgressEnforced` says which entries are not enforced.

An `open` workstation behind an edge instance reaches other public IPv4 addresses over TCP only,
and no IPv6 address. [Traffic behind an edge instance](https://docs.ringleader.dev/security/outbound/filtering/#traffic-behind-an-edge-instance)
says which private addresses and which UDP traffic it does not reach. The exceptions are the
destinations Ringleader needs, its attached Integrations' endpoints and your cloud's own
services, such as the metadata server.

## Network processes and edge VMs

An hcs, vz or qemu workstation needs no Edge to enforce a policy, record an `audit` policy or
inject a credential. With no Edge for the workstation's provider, its network process enforces its
policy and adds its credentials. For an `audit` policy it records the allowed connections.
Nothing is built or downloaded for it. A namespace administrator can declare an Edge for the
provider to run an edge VM instead. The edge VM then serves the namespace's workstations on that
provider that have a policy or an injected credential.

- The Ringleader daemon on your computer runs one small edge VM for each declared Edge that has
  workstations there to serve. The VM has 2 vCPUs and 1 GiB of memory. It enforces egress policies by name and by
  address, and injects credentials for rules that allow it. `rl status` lists the edge VMs on your
  computer and what each is doing.
- On Windows, the Ringleader VM Service counts each edge VM as one of your workstations against
  the [Limits for each Windows account](https://docs.ringleader.dev/workstations/providers/windows/#limits-for-each-windows-account).
  Its disk and its 1 GiB of memory count too.
- The daemon restarts an edge VM that stops working and rebuilds it if a restart does not help.
  It deletes the edge VM once its last workstation is gone.
- Moving a workstation between its own network process and an edge VM does not restart it.

### qemu network cards

Most qemu workstations run behind their network process from the start. They do not restart when
they get their first egress policy or injected credential, or when they lose their last. These
qemu workstations do restart then, because their network cards change:

- A node-bound workstation set to `loopback: true`. It restarts on the restricted network when its
  first policy or injected credential arrives, and restarts on the open network when its last one
  goes. A `HostAccessOverridden` condition says so. If your organization's host-access rules set
  `loopback: deny`, it runs on the restricted network from the start and does not restart.
- A workstation on a computer that cannot give it a restricted network. It restarts when a
  `strict` or `audit` policy holds it closed, and again when that policy goes.
- A workstation that was already running when you updated Ringleader and has not restarted since.
  It restarts once, when its first policy or injected credential arrives.

## Checks when you apply a policy

`rl apply` checks a `strict` or `open` policy against the workstation's provider when you apply the
workstation:

- **A local workstation** needs no Edge, because its own network process serves it. It does not
  have to name its provider: a new one that names none is created on, and checked against, your
  computer's [Default local provider](https://docs.ringleader.dev/workstations/basics/#default-local-provider).
  If your computer has no default, `rl apply` refuses the workstation and says why.
- **A cloud workstation** names its provider. The namespace must hold an Edge for that provider
  wherever [Enforcement by provider](#enforcement-by-provider) says the policy needs one.

A local workstation from an earlier release may have no provider in its record. Ringleader then
refuses the policy until you add the provider to the workstation's file. Its `status.provider` shows
which one it runs on.

The check is on the merged policy: the workstation's own `egress` block plus the
WorkstationConfig layers it inherits. It does not require a matching region or a ready edge
instance, and an Edge that is being deleted does not count. `EgressEnforced` reports what is
actually held once the workstation is set up.

[Requirements for an audit policy](https://docs.ringleader.dev/security/outbound/reach-audit/#requirements-for-an-audit-policy)
says what Ringleader checks for `audit`.

A WorkstationConfig is never refused for the workstations it reaches, and one that declares
`audit` needs no provider of its own. Each workstation is checked when you next change its own
`egress`, provider, labels or `configs`. Until then, its `EgressEnforced` condition reports what
is held.

## Check what a workstation enforces

The `EgressEnforced` condition says whether the declared policy is in force, and why not when it
is not.

1. Describe the workstation:

   ```bash
   rl workstation describe my-box
   ```

2. Read `EgressEnforced`. With `True` and reason `Enforced`, the message names what holds the
   policy. On a cloud it names the provider, how many destinations it holds and the identifier of
   the firewall objects. You can check those objects in your cloud console. On hcs, vz and qemu it names
   the edge VM that holds it, or the workstation's own network process when no Edge is declared.
3. For a declared Edge, run `rl edge describe <name>` to see its own status.

[`EgressEnforced` reasons](https://docs.ringleader.dev/reference/resources/workstation/#egressenforced-reasons) lists every
reason.

## Fix a held-closed workstation

A workstation that reports `NoEdge` or `GatewayNotServing` is held closed or unrestricted until
something serves it. Pick the fix that matches the reason and the provider:

- For `NoEdge` on a cloud, ask a namespace administrator to
  [declare an Edge](https://docs.ringleader.dev/security/outbound/edge-management/#declare-an-edge) for the
  provider and region. With a `strict` or `bestEffort` policy, you can instead declare every
  destination as a `cidr`, which your cloud's firewall holds without an Edge. For `audit`, remove
  the policy or have an administrator declare the Edge.
- For `NoEdge` on hcs, vz or qemu, delete the workstation and create it again. It was created
  before its provider gave each workstation its own address, so no network process can serve it.
- For `GatewayNotServing` on a cloud, wait while the Edge's VM is built. Or run
  `rl edge describe <name>` to see why it is not holding the policy. On AWS and Azure, a common
  cause is a workstation in a subnet that already has a route table of its own. Move it to the
  subnet your onboarding reserved for the workstations an Edge serves.
- For `GatewayNotServing` on hcs, vz or qemu with no Edge declared, the network process has not
  confirmed the policy. Check the message, which says whether the workstation reaches nothing yet
  or is still open. With an Edge declared, wait while its VM is built, or run
  `rl edge describe <name>`.

## Next steps

- For declaring and deleting the Edge that serves a cloud workstation, see
  [Edge management](https://docs.ringleader.dev/security/outbound/edge-management/).
- [Filtering behavior](https://docs.ringleader.dev/security/outbound/filtering/) says what a workstation
  reaches behind an edge instance and what filtering cannot stop.
- [`EgressEnforced` reasons](https://docs.ringleader.dev/reference/resources/workstation/#egressenforced-reasons) lists
  every reason the condition reports.

