> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/cgw/1.12/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/cgw/1.12/configuration/container-privileges.md).

# Container privileges

Every container the Connectivity Gateway (CGW) chart renders gets the
capabilities its own work needs, and nothing beyond them. Where a container
needs more — an older image, a node that pre-loads nothing — or where a cluster
policy demands less, each container has an `additionalSecurityContext` value
that is merged over what the chart renders.

## What the chart grants

| Container | Kind | `securityContext` |
| --- | --- | --- |
| `init-ip` | init | `NET_ADMIN` |
| `init-vti` | init | `NET_ADMIN` |
| `init-gre` | init | `NET_ADMIN` |
| `ip-setup` | init | `NET_ADMIN` |
| `iptables` | init | `NET_ADMIN` |
| `init-script` | init | `NET_ADMIN`, `privileged: true` |
| `vxlan-controller-agent-init` | init | `NET_ADMIN` |
| `vxlan-controller-ip-setup` | init | `NET_ADMIN` |
| `ipsec` | main | `NET_ADMIN` |
| `bird` | main | `NET_ADMIN` |
| `vrrp` | main | `NET_ADMIN` |
| `pcap` | main | `NET_RAW` |
| `vxlan-connector-*` | main | `NET_ADMIN` |
| `vxlan-controller-agent` | main | `NET_ADMIN` |
| `debug` | main | `privileged: true` |
| `bird-config-watcher` | main | `runAsGroup: 0` |
| `radvd` | main | `NET_RAW` |
| `ping-exporter` | main | `NET_RAW` |
| `ping-prober` | main | none |
| `bird-exporter` | main | none |
| `ipsec-exporter` | main | none |
| `conntrack-exporter` | main | none |
| `rclone` | main | none |

The containers with no `securityContext` run on the capabilities the container
runtime grants by default. That set includes `NET_BIND_SERVICE`, which is why
charon can bind UDP/500 with `NET_ADMIN` alone, and `NET_RAW`, which is what
`ping-prober` pings with.

`bird-config-watcher` gets no capability, but runs with group `0`. bird creates
its control socket as `root:root` with mode `0660`, and connecting to a socket
needs write access to it. The group grants that access, while the container
keeps the image's non-root user.

`ping-exporter`, `radvd` and `pcap` state `NET_RAW` rather than relying on that
default, because the default is the runtime's to change and a cluster policy
can drop the capability from it. Each of them opens a socket that needs it: an
ICMP socket, an ICMPv6 socket, and the `AF_PACKET` socket of the capture, for
which no other capability substitutes. `pcap` is the clearest case — its
`dumpcap` carries `cap_net_raw+eip` as a file capability, and a file capability
only takes effect while the capability is in the container's bounding set.

`debug` is `privileged` on purpose — `ip xfrm state` and `tcpdump` on a
neighbour's traffic is the point of it. That also makes it a standing
escalation path in the pod, so keep `debug.enabled: false` outside of an
investigation.

`init-script` is `privileged` because the script is yours and the chart cannot
know what it does. A script that only configures interfaces runs with:

```yaml
initScript:
  additionalSecurityContext:
    privileged: false
```

## Overriding a container's `securityContext`

Every block that renders a container takes an `additionalSecurityContext`:

```yaml
bird:
  additionalSecurityContext:
    capabilities:
      drop: ["ALL"]
```

A key you set replaces the chart's, one level deeper for `capabilities`. So the
`drop` above keeps the `NET_ADMIN` the chart adds, while

```yaml
vrrp:
  additionalSecurityContext:
    capabilities:
      add: ["NET_ADMIN", "SYS_MODULE"]
```

states the whole set — the list is not appended to the chart's. The value is a
`securityContext` fragment; a bare list of capabilities is rejected with an
error naming the container.

The values are `ipsec.additionalSecurityContext`,
`ipsec.initIp.additionalSecurityContext`,
`ipsec.initVti.additionalSecurityContext`,
`bird.additionalSecurityContext`,
`bird.birdConfigWatcher.additionalSecurityContext`,
`vrrp.additionalSecurityContext`, `pcap.additionalSecurityContext`,
`radvd.additionalSecurityContext`, `pingExporter.additionalSecurityContext`,
`gre.additionalSecurityContext`, `ipSetup.additionalSecurityContext`,
`iptables.additionalSecurityContext`, `initScript.additionalSecurityContext`,
`debug.additionalSecurityContext`, `vxlan.additionalSecurityContext` and
`vxlanController.additionalSecurityContext`.

## When `init-vti` needs more

`init-vti` creates the VTI interface with `NET_ADMIN`, but it also sets
`net.ipv4.conf.<vti>.disable_policy=1` on it. Without that flag, packets that
have already been decapsulated match the IPsec policy a second time. `/proc/sys`
is mounted read-only in a container, so the write needs `privileged: true`
unless the value is set on the pod's network namespace from outside and
inherited by the interface, which requires one of:

- pod `sysctls`, if the node's kubelet allows
  `net.ipv4.conf.default.disable_policy` as an unsafe sysctl:

  ```yaml
  sysctls:
    - name: net.ipv4.conf.default.disable_policy
      value: "1"
  ```

- the CNI `tuning` plugin in the network attachment the pod uses, which needs
  no node configuration:

  ```json
  { "type": "tuning", "sysctl": { "net.ipv4.conf.default.disable_policy": "1" } }
  ```

Either way `default.` applies to every interface created in that namespace
afterwards, not only the VTI.

Where neither is in place, or where `ipsec.image.tag` is a `v1.5.x` whose
entrypoint still runs `modprobe ip_vti` — that needs `SYS_MODULE` and the
`/lib/modules` mount — restore the previous behaviour with:

```yaml
ipsec:
  initVti:
    additionalSecurityContext:
      privileged: true
```

A VTI that was never created shows up as `Cannot find device "vti<key>"` in the
`ipsec` container, because the `modprobe` failure itself is silent.

## Pod Security Standards

With `debug` and `initScript` disabled and `init-vti` reduced as above, the
pod's containers hold `NET_ADMIN` and nothing else. That is still above the
`baseline` standard, which forbids adding any capability except
`NET_BIND_SERVICE`, so a namespace enforcing `baseline` or `restricted` cannot
run the gateway: configuring links and installing XFRM policies is what the
gateway does.
