# Effects of injection on a workstation

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


> Injection changes how a workstation reaches the hosts you name, and it can change how it reaches everything else.


Injection changes how a workstation reaches the hosts you name, and it can change how it reaches
everything else. Ringleader decrypts the traffic to the hosts a rule names, so a tool that cannot
trust Ringleader's certificate fails there. The sections below say what changes, so you can tell a
tool that fails on the certificate from an injection that did not work.

## Requests to a named host

For each request to a host you name, Ringleader does four things:

- It sets the header on every request, including each request on a reused connection. A
  header of that name that the workstation sent is replaced. If a tool refuses to run
  without a key of its own, give it any placeholder value, because the placeholder never
  reaches the API.
- It removes the key from the response. Where the key appears in a response header or
  body, it is replaced by its `${secret:…}` reference. An API that echoes the request back
  then shows `Bearer ${secret:github-pat/token}`. The key is matched exactly as it was sent. A
  response that carries it in another encoding returns it to the workstation. Two examples are
  an API that echoes the key base64-encoded, and one that decodes a base64 value and echoes the
  plain key. [Inject a key for a service that takes Basic authentication](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/#inject-a-key-for-a-service-that-takes-basic-authentication)
  shows the base64 form.
- It checks the request's `Host` header. A request naming a different host from the one the
  connection was opened to gets `421 Misdirected Request`, and the connection is closed.
- It removes the `Accept-Encoding` header, so responses come back uncompressed. A response
  compressed with anything other than gzip closes the connection.

To read these requests, Ringleader decrypts the HTTPS traffic to the named hosts. Each
workstation gets its own certificate authority, valid only for the hosts named for that
workstation. On Debian, Ubuntu and Alpine images, Ringleader installs it in the system trust
store and sets these variables:

- `SSL_CERT_FILE`, `CURL_CA_BUNDLE`, `REQUESTS_CA_BUNDLE`, `GIT_SSL_CAINFO` and
  `CARGO_HTTP_CAINFO`, set to the combined bundle, `/etc/ssl/certs/ca-certificates.crt`.
- `NODE_EXTRA_CA_CERTS`, set to the Ringleader certificate alone,
  `/usr/local/share/ca-certificates/ringleader-egress-gateway.crt`.

So `curl`, `git`, Python's `requests`, Node.js and Go programs accept the connection with no
setup of your own. The installs Ringleader runs for `npm`, `pypi`, `go` and `mise`
packages trust it too, as [Package installation](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/package-installation/)
covers. These values replace the same variables set in a
[WorkstationConfig](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/). A value set in a shell
startup file wins over them.

A tool with its own trust store, or one that checks for one fixed certificate, rejects the
connection. That includes a client that ignores the six certificate variables, such as a Java
keystore, `apt` or Rust's `webpki-roots`. So does a client that only speaks HTTP/2, because a
named host is served over HTTP/1.1. Leave such a host out of your rules, or follow
[Exclude a host from decryption](https://docs-stg.ringleader.dev/security/credentials/host-inspection-exclusion/#exclude-a-host-from-decryption).

## Traffic to every other host

Traffic to every other host is not decrypted, and its bytes are not changed. Ringleader looks up
each host name itself and connects to the address it gets, and it refuses a name that resolves to
a private address.

What else changes depends on where the workstation runs:

- A cloud workstation with no egress policy is moved behind its edge instance. From there it can
  reach any public address on any TCP port, and
  [Traffic behind an edge instance](https://docs-stg.ringleader.dev/security/outbound/filtering/#traffic-behind-an-edge-instance)
  says what it can no longer reach. Until an edge instance serves it, the workstation runs as
  before, without the key.
- A cloud workstation behind an edge instance also stops answering at its own public address.
  `rl shell` reaches it through a port on the edge instance instead, as
  [Access to a workstation behind an Edge](https://docs-stg.ringleader.dev/security/outbound/edge-management/#access-to-a-workstation-behind-an-edge)
  explains.
- A workstation with an egress policy does not need to list the named hosts in it. Each
  rule's host is added to what the workstation may reach, on ports 80 and 443.
- An hcs, vz or qemu workstation reaches the network through its own network process. When
  the namespace declares an Edge for its provider, it uses the edge VM instead, as
  [Network processes and edge VMs](https://docs-stg.ringleader.dev/security/outbound/enforcement/#network-processes-and-edge-vms)
  describes. What it can no longer reach is in
  [Traffic behind an edge instance](https://docs-stg.ringleader.dev/security/outbound/filtering/#traffic-behind-an-edge-instance).

## Moves and restarts

Moving a local workstation between its own network process and an edge VM does not restart it.
What a workstation reaches while nothing serves it yet is in
[Held-closed workstations](https://docs-stg.ringleader.dev/security/outbound/enforcement/#held-closed-workstations). Some qemu workstations do restart when their first key arrives or their last one goes, and
[qemu network cards](https://docs-stg.ringleader.dev/security/outbound/enforcement/#qemu-network-cards) says which.

A workstation created before its provider gave each workstation its own address cannot be served
and reports `NoEdge`. Delete it and create it again, as
[Fix a held-closed workstation](https://docs-stg.ringleader.dev/security/outbound/enforcement/#fix-a-held-closed-workstation)
says.

## Containers on the workstation

On a workstation that has Ringleader's certificate and declares the `docker` or `kind` devtool,
Ringleader gives Docker containers the same certificate. This covers `docker run`, a Docker
build step, a pod in a cluster the kind devtool creates, and a container that
[Devcontainer workstations](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/devcontainers/) describes.
Docker can pull an image from a registry that is decrypted too.

The certificate reaches new and running containers when Ringleader issues a new one. Docker,
the kind node, and the container do not restart. A container's connection is decrypted on every
provider this page covers.

A hand-created kind node gets the certificate for its own image pulls automatically. It reads
the certificate only when the node starts, so restart the node after Ringleader issues a new
certificate. Its pods need the configuration under
[Create a kind cluster that trusts the certificate](#create-a-kind-cluster-that-trusts-the-certificate).

## Containers the certificate does not reach

The certificate does not reach these containers:

- Podman, nerdctl, a runtime you install yourself, and a container created before the
  workstation received its certificate. Recreate that container after the certificate arrives.
- A container image that sets `SSL_CERT_FILE` or `CURL_CA_BUNDLE` itself. Ringleader keeps the
  image's value, so the image keeps using its own certificate bundle.

## Create a kind cluster that trusts the certificate

Pods in a kind cluster you create yourself need extra configuration when you create the cluster.
The workstation must declare the `docker` or `kind` devtool and hold Ringleader's certificate, or
these paths do not exist. Add the same node configuration for every node that runs pods. It makes
the cluster's image pulls and pods use the certificate:

```yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
  [plugins."io.containerd.grpc.v1.cri".registry]
    config_path = "/etc/containerd/certs.d:/etc/docker/certs.d:/etc/ringleader/egress-trust/certs.d"
  [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
    BinaryName = "/usr/local/bin/ringleader-oci-trust"
nodes:
- role: control-plane
  extraMounts:
  - hostPath: /etc/ringleader/egress-trust
    containerPath: /etc/ringleader/egress-trust
    readOnly: true
  - hostPath: /usr/local/lib/ringleader/ringleader-oci-trust
    containerPath: /usr/local/bin/ringleader-oci-trust
    readOnly: true
```

The node's image pulls and its pods then use the certificate, and they keep working when
Ringleader issues a new certificate.

## Next steps

- [Injected credentials](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/) adds a key to a request as it
  leaves the workstation.
- [Host inspection and exclusion](https://docs-stg.ringleader.dev/security/credentials/host-inspection-exclusion/) keeps a
  client that fails on the certificate from being decrypted.
- [Filtering behavior](https://docs-stg.ringleader.dev/security/outbound/filtering/) says what filtering by name can
  and cannot stop.

