# Enforced protections

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


> Which protections hold on every workstation as soon as it exists, which you turn on yourself, and which your organization sets on your computer.


A rule is a limit on what a workstation can do or reach: which folders of your computer it sees, which
hosts it connects to, which keys it holds. Ringleader enforces some rules outside the workstation, so the
coding agent cannot change them. [Rule locations](https://docs.ringleader.dev/security/model/rule-locations/) says
where else a rule can live.

Some rules hold on every workstation with nothing configured. You turn on others by declaring them in a
workstation's file or in a Policy, and your organization can set a few on your computer. This page lists
each group and where to read more.

## Rules that hold by default

These rules hold with nothing configured, as long as the workstation runs on vz, hcs, qemu or a cloud:

- The boundary between the workstation and your computer is the processor's hardware virtualization.
  That is Apple's Hypervisor.framework on a Mac, as
  [Mac workstations (vz)](https://docs.ringleader.dev/workstations/providers/mac/) describes, Hyper-V through
  the Host Compute Service on Windows, KVM on Linux, or your cloud's own VMs. The network process that carries a local workstation's traffic is
  Ringleader's own.
- Your own files stay out. A vz workstation shares a folder only when its spec lists it under
  `mounts`, and an hcs, qemu or cloud workstation shares none at all. A `local` source in a
  WorkstationConfig's `spec.sources` copies a folder from your computer into the workstation each time
  the configuration is applied.
- Your computer's own services stay out. A vz workstation reaches only what Ringleader itself needs at
  your Mac's `127.0.0.1`, and Ringleader refuses an hcs workstation's connections to your PC's own
  addresses. [Loopback reach](https://docs.ringleader.dev/workstations/connectivity/host-access-loopback/#loopback-reach)
  says when a qemu workstation reaches your computer's `127.0.0.1`. Other computers on your network
  are not kept out.
  [Keep a workstation off your local network](https://docs.ringleader.dev/security/outbound/outbound-restrictions/#keep-a-workstation-off-your-local-network)
  shows the block that stops it.
- The workstation's own identity can read its own record and nothing more. The `self:power` and
  `sa:assume` permissions stay off until an administrator grants them.
- On AWS and Azure the workstation has no cloud identity of its own unless an administrator gives it
  one. On Google Cloud every VM runs as some service account.

## Rules you turn on

You turn the rest on by declaring it. Each of these is then enforced outside the workstation too:

- To restrict where the workstation may connect, declare an `egress` block with `enforcement: strict`.
  [Outbound restrictions](https://docs.ringleader.dev/security/outbound/outbound-restrictions/) shows how, and
  the `EgressEnforced` condition on the workstation shows what is in force.
- To keep a key off the workstation, write a credential injection rule. It is an Integration, the
  resource that connects workstations to a shared service, of `type: httpProxy`. Ringleader then adds
  the key to each request to the host you name, and decrypts only the hosts you name. [Injected credentials](https://docs.ringleader.dev/security/credentials/injected-credentials/) shows how.
- To set a limit a member cannot widen, write a Policy or an OrgPolicy. It limits which git repositories
  a workstation may clone, where it may connect and which model an `llm` Integration may name.
  [Policy and OrgPolicy](https://docs.ringleader.dev/reference/resources/policy/) lists the settings.
- To learn what a workstation reaches before you restrict it, give it an `audit` policy.
  [Workstation reach audit](https://docs.ringleader.dev/security/outbound/reach-audit/) shows how.
- To have a workstation stop or delete itself, set a lifetime on it, as
  [Starts, stops and restarts](https://docs.ringleader.dev/workstations/lifecycle/starts-stops-restarts/) and
  [Deletion and delete deadlines](https://docs.ringleader.dev/workstations/lifecycle/deletion-deadlines/) describe.

A refused policy names the field and the value, and Ringleader records the decision in its audit log.
Ringleader judges a policy only for a workstation it stores: a cloud workstation, or a
[node-bound](https://docs.ringleader.dev/workstations/basics/#node-bound-workstations) local one. A workstation in
the `local` namespace is stored only on your computer, and so is one an earlier release of `rl`
stored there in another namespace. Of a policy's settings, only the ones in
[Rules your organization sets for your computer](#rules-your-organization-sets-for-your-computer)
reach it.

*Illustration: A request from the coding agent inside the workstation names a host and carries no key. Outside the workstation, its network process or Edge adds the injected key from a Secret for that host only. A host no rule names gets no key and nothing decrypted. The request arrives at the named host with the key, and the key is never on the workstation.* Credential injection: the key is added where the connection leaves the workstation, for the named host only.


## Rules your organization sets for your computer

An organization can forbid its members' computers to store workstations, and it can forbid
workstation providers such as `qemu` or `gcp`. It sets these with `device.storeWorkstations`
and `workstationProviders` in a [Policy or an OrgPolicy](https://docs.ringleader.dev/reference/resources/policy/).
It can also limit what a workstation reaches of your computer, as
[Limits on what a workstation reaches](#limits-on-what-a-workstation-reaches) describes.
A workstation stored only on your computer never reaches Ringleader, so Ringleader enforces these
rules on your computer. Here is what happens there:

- When you sign in, your computer fetches your organization's answers for you and keeps them. It
  fetches them again every five minutes while you stay signed in and the Ringleader daemon runs.
  `rl auth logout` does not remove them.
- `rl`, the TUI and the desktop app refuse to create a Workstation or WorkstationPool stored on
  your computer when it breaks an answer. They also refuse to change one to a provider your
  organization forbids. That covers every workstation and pool stored on your computer, in any
  namespace, orphaned workstations included. When your organization
  forbids storing, the message tells you to create the workstation in the organization's
  namespace while signed in.
- If you belong to two organizations, the stricter answer holds in `local` and in a namespace
  that exists only on your computer. In an organization's namespace, your computer follows that
  namespace's answer.
- A workstation that already breaks a rule keeps running. You can stop it or delete it. `rl` and the TUI refuse to start it, and the
  Ringleader daemon does not start it after your computer restarts or the daemon restarts.
- The local container runtime, which `rl local-runtime create` makes, may be stored on your
  computer even when your organization forbids storing. It still follows `workstationProviders`.
  If you change the runtime's workstation with `rl apply` or `rl edit`, it loses that exception
  until you run `rl local-runtime create` again.
- An agent session is not checked.

### Limits on what a workstation reaches

An organization limits what a workstation reaches of your computer with `device.hostAccess`. The
limits cover the folders it shares, a `local` source, your computer's `127.0.0.1`, service forwards
from your computer into a workstation (reverse forwards) and the local container
runtime.
[Workstation reach on the computer](https://docs.ringleader.dev/reference/resources/policy/#workstation-reach-on-the-computer)
describes each setting. Your computer applies them to every workstation it runs, whether it is
stored only on your computer or node-bound. `reverseForwards` also holds for a cloud workstation,
because your computer is just as exposed whichever workstation is at the other end.

When a change asks for more than the limit allows, your computer refuses it and names the field.
It checks `rl apply`, `rl edit`, `rl binding enable`, and a LocalBinding you write yourself. For
example, under `reverseForwards: deny` a LocalBinding that adds a reverse port is refused with:

```text
refused by the organization's device rules: spec.reversePorts[0] is a reverse forward, and your
organization's host-access rule does not let a workstation reach a service on this computer through
a reverse forward
```

The message names the field but not the policy that set it. An ordinary port forward from a
workstation to your computer, such as a LocalBinding's `ports`, is not limited. Only access that your change adds
or widens is refused. You can still edit a workstation that already has more access, as long as
the edit leaves that access as it is.

A workstation that already has more access than the limit keeps running, and Ringleader does not
stop or restart it for the limit. The limit takes effect the next time the workstation starts:
after you stop and start it, or after your computer restarts. When the Ringleader daemon restarts,
it applies a changed `mounts` limit to a vz workstation's shared folders by stopping and starting
that workstation.

Two settings keep a workstation from starting instead of starting it with less:

- Under `localRuntime: deny`, `rl local-runtime create` is refused. A local runtime you already
  have can be stopped or deleted, but not started.
- Under `loopback: deny`, a qemu workstation on a computer that cannot give it a restricted
  network always reaches your computer's localhost. It can be stopped or deleted, but not
  started.

While the limit narrows a workstation, `rl workstation describe <name>` shows a
`HostAccessLimitedByOrg` condition. It names each field the limit changed and the setting that
changed it, but not the policy:

```text
your organization's host-access rules limit this workstation, so it runs with less host access
than it was given: spec.hostAccess.loopback (loopback: deny). What you set is kept, and it
applies again at the next start after the rule is lifted
```

Ringleader keeps what you set in the workstation's spec. When your organization lifts the limit,
the next start gives the access back, with no edit.

An administrator of your computer can remove these rules. [Rules on your own computer](https://docs.ringleader.dev/security/model/protection-limits/#rules-on-your-own-computer)
says how, and what an organization can do about it.

## Next steps

- [Outbound restrictions](https://docs.ringleader.dev/security/outbound/outbound-restrictions/) writes the `egress` block.
- [Injected credentials](https://docs.ringleader.dev/security/credentials/injected-credentials/) adds a key to a request outside the workstation.
- [Policy and OrgPolicy](https://docs.ringleader.dev/reference/resources/policy/) lists the limits an organization can set.
- [Edge management](https://docs.ringleader.dev/security/outbound/edge-management/) says when a workstation needs an Edge.
- [Limits of protection](https://docs.ringleader.dev/security/model/protection-limits/) lists the limits to plan for.

