DocsSecurity
On this page
Communication and trust
Every connection Kubernanny makes or accepts and what protects it. This is the part of Kubernanny that has to be right; read it before exposing an agent. The wire format is specified in PROTOCOL.md, ports and NetworkPolicies are in IN-CLUSTER.md, and what an attacker in each position can do is in SECURITY.md.

Principles#
- The cluster is the source of truth, the agent the only thing that touches it. The app never talks to Kubernetes. It talks to one agent per cluster.
- End to end, whatever the path. Every call between app and agent is a Noise handshake between the device's key and the agent's pinned key. TLS, plain HTTP in the LAN, a VPN, a proxy or a relay only carry ciphertext.
- No secret crosses the network. Devices prove a private key that never leaves them; there is no token to steal on the wire or in the agent's Secrets.
- No backend of ours in the trust path. No account, no telemetry. The optional relay (0004) forwards ciphertext and can be self-hosted or switched off.
- Requests name problems, never targets. An action is "fix issue X", and the agent takes namespace, name and kind from its own check. No request can point the agent at anything else.
- Only the Kubernetes API is trusted to cause actions. Data from Prometheus, Alertmanager, Grafana and Loki is shown, never acted upon.
The channels#
| # | From → to | Protocol | Authenticates | Confidential against | Carries |
|---|---|---|---|---|---|
| 1 | App / browser → agent | Noise IK per call over HTTP(S) POST /api/e2e |
device key and agent key, every call | everyone but the device and the agent, including ingress, proxies, relay | status, details, logs of broken pods, action requests |
| 2 | Phone → agent, once | the same, POST /pair inside |
one-time code + the device key from the handshake | the same | device name in, device id out |
| 3 | Agent → Kubernetes API | HTTPS | ServiceAccount token (projected, rotated) | network; server certificate checked against the cluster CA | list/get; patch, create and delete (finished pods) for the enabled actions |
| 4 | Agent → Prometheus, Alertmanager, Grafana, Loki | HTTP inside the cluster | none | by your CNI, if it encrypts (WireGuard, IPsec) | GET of read endpoints only |
| 5 | Agent → notification service | HTTPS (HTTP only to *.svc) |
URL / token you configure | network | cluster name, issue titles and causes (or only counts) |
| 6 | Prometheus → agent :9100 |
HTTP inside the cluster | none | by your CNI | counts and scores, no names |
| 7 | Operator → agent log | kubectl logs |
your kubeconfig | network | QR code with a one-time code and the agent's public key |
| 8 | Operator → admin CLI | kubectl exec + Unix socket in the pod |
your kubeconfig (pods/exec) |
network | new pairing code, device list, revoke |
| 9 | Agent → vulnerability database (off by default) | HTTPS to api.osv.dev or your mirror (HTTP only to *.svc) |
server certificate | network | component package names and versions, advisory ids; no cluster data |
| 10 | Agent → relay, outbound WebSocket (off by default) | wss://, frames around the sealed bodies of channel 1 |
the agent proves its key at registration; TLS for the relay's name | everyone but device and agent for content, the relay included; TLS for the metadata | channel 1's ciphertext, a heartbeat |
| 11 | App / browser → relay (when the agent is out of reach) | HTTPS POST /v1/agents/{agentId}/e2e |
nothing at the relay; inside, the same handshake as channel 1 | the same as channel 1 | the same bytes as channel 1 |
| 12 | Agent → relay → FCM (→ APNs) → phone: native push (off until a device opts in; needs channel 10) | a Push frame on channel 10's socket; HTTPS from the relay to FCM with the relay's service account |
the agent's registration proof (relay); mode_auth HPKE with the pinned agent key (phone) |
everyone but the agent and the one device: relay, Google, Apple | title and body of a notification (or only counts with detail: minimal), sealed per device; FCM token, platform and key id in clear for the relay and FCM |
| 13 | Agent → public container registries (off by default) | HTTPS to Docker Hub, ghcr.io, quay.io, registry.k8s.io | server certificate; an anonymous pull token per repository | network | repository names of recognised components' images; no tag, no cluster data, no credentials |
1. App / browser → agent#
App ── HTTPS or plain HTTP ──▶ (Ingress) ──▶ kubernanny :8080 POST /api/e2e
0x01 | Noise message 1 (device key encrypted, request encrypted)
◀── 0x01 | message 2 | frames (answer, readable only by this device)- Confidentiality and integrity. The request is encrypted to the agent's static key, the answer to the keys of exactly this call. Whoever carries the bytes (ingress, a corporate proxy, the LAN, a relay) sees sizes and timing, nothing else, and any change makes the call fail.
- Authentication, both ways, every call. The device proves its private key in the handshake (Noise
ss,se); the agent proves its own. There are no bearer credentials, no cookies, so no CSRF and nothing to replay from a log. - Pinned agent key. The app stores the agent's public key at pairing. A different machine answering under the agent's address (DNS hijack, a rogue Wi-Fi, a compromised ingress) cannot answer at all.
- Transport. Because of the above, the address may be plain
http://in a LAN or VPN. Only fetching a key that is not pinned yet (manual pairing without the QR code) is restricted tohttps://,localhostor the web UI's own origin (transportAllowed,app/src/app/core/agent-client.service.ts). - Replay and freshness. The agent remembers each call's ephemeral key for 10 minutes and refuses calls whose clock is more than 5 minutes off; the device corrects its clock from the agent's authenticated answer.
- The public port answers only
/healthz,/readyz,/api/identity(the public key),/api/e2eand the web UI. Every other route is reachable only through the internal socket after a successful handshake (0003); on the port it answers 401E2E_REQUIRED. - Abuse. A handshake costs the agent four X25519 operations; a token bucket (60, refilled at 20 per second) caps them. Bodies are at most 64 KiB.
- Authorisation. Reads are open to every paired device. Actions are bound to open issues (
POST /actions/restart?issue=pods/default/Deployment/web): the agent looks the issue up in its own snapshot and runs the action stored there (409 when the issue is gone, 404 when it does not offer that action). There is no parameter for a namespace, name or kind. - Audit. Every action, log read, pairing, code and revocation is logged with the device's name and id.
- Browser hardening on everything the agent serves: a Content Security Policy that allows scripts only from the agent's own origin (no inline scripts, no eval), no framing,
nosniff,Referrer-Policy: no-referrer,Cache-Control: no-storeon the API. No HSTS: the agent never terminates TLS, so HSTS belongs on the ingress. The UI loads nothing from third parties and Angular escapes every value from the cluster. - Reachability is still worth limiting: the chart's NetworkPolicy lets port 8080 accept connections only from the ingress controller's namespace, and a VPN-only entry point keeps the agent out of internet scanners' sight.
2. Pairing#
sequenceDiagram
participant A as Agent
participant L as Pod log
participant O as You (kubectl)
participant P as Phone
A->>L: QR + link: url, one-time code, agent public key
O->>L: kubectl logs
O->>P: scan / open link
P->>P: new key pair for this cluster, pin the agent key
P->>A: Noise message 1: POST /pair { code, name }
A->>A: code valid, unused, < 60 min, < 5 failures?
A->>A: store { id, name, device public key from the handshake }
A-->>P: message 2: { deviceId, cluster }
A->>L: "pairing code redeemed by iPhone, Safari"- The code is 10 characters from a 31-letter alphabet, works once and expires after 60 minutes. Wrong attempts never burn it, directly or through the relay: past five in 10 minutes (a blank code counts as one) they are answered
PAIRING_RATE_LIMITED, and the right code is compared first, so it always pairs. Guessing is bounded by the budget all unknown keys share (PROTOCOL.md). A new code invalidates the previous one, and a new pairing is announced through the notification channels. - The log may be shipped to Loki and read by many people. What they see is a code that is used or expired and a public key; neither is a credential.
- A paired device can create a code for the next one; with kubectl,
kubectl -n kubernanny exec deploy/kubernanny -- node dist/cli.js pairprints a fresh banner. - Without the QR code (address and code typed by hand), the agent key is fetched once over HTTPS or a port-forward, and the app shows its fingerprint, which the log shows too.
- A pairing link never pairs by itself: anyone can make one. The app shows name, address, relay and the agent key's fingerprint and pairs on a tap; a link that would give a cluster already in the app another key is refused unless the person explicitly replaces it (SECURITY.md).
3. Agent → Kubernetes API#
- HTTPS to
KUBERNETES_SERVICE_HOST, server certificate verified against the ServiceAccount CA (NODE_EXTRA_CA_CERTS); TLS verification is never disabled. - The ServiceAccount token is read from the projected volume on every request, so rotation needs no restart.
- What the ServiceAccount may do is listed in PERMISSIONS.md, generated from the code. A test (
agent/src/rbac.spec.ts) fails if it changes.
4. Agent → Prometheus, Alertmanager, Grafana, Loki#
- Reached directly over cluster DNS (
http://prometheus-operated.monitoring.svc:9090), not through the API server's service proxy, which would need a grant reaching every internal service. - GET only, no credentials sent, redirects refused, 10 s timeout, responses over 8 MB refused.
- Untrusted by design. These endpoints are found by the images that run them, so anyone who can run a pod with a Prometheus image could answer instead. Issues from these sources are stripped of actions (integrations with
untrusted = true); theIntegrationbase class enforces it: only untrusted integrations get the Prometheus client andthis.http(). Pin the real ones withPROMETHEUS_URL/ALERTMANAGER_URLif that matters to you.
5. Agent → notifications#
NTFY_URLandWEBHOOK_URLmust be HTTPS; plain HTTP only for a service inside the cluster (*.svc). Redirects are refused.- What leaves the cluster: the cluster name, issue titles and causes. With
NOTIFY_DETAIL=minimalonly the cluster name and counts. Use that for public services like ntfy.sh, or self-host ntfy. - Secrets in webhook URLs belong in
notifications.existingSecret, not in Helm values.
6. Metrics#
:9100/metrics has no authentication and carries only numbers. It is not routed by the chart's ingress; the NetworkPolicy lets only the monitoring namespace reach it. METRICS_PORT=0 turns it off.
7. The log#
Shows the pairing QR code, the agent's fingerprint and the audit trail. No credential. Device names are cleaned (control characters removed), so a device cannot forge log lines.
8. Admin CLI#
node dist/cli.js pair | devices | revoke <id> inside the pod talks to the internal socket. Only someone allowed to exec into the pod can run it, and that person could read the agent's Secrets anyway.
9. Vulnerability database#
Only while the vulnerabilities module is switched on (Helm vulnerabilities.enabled, ENABLED_MODULES or the app); it is off by default. The agent sends OSV package names and versions (github.com/argoproj/argo-cd/v3 at 3.1.2, k8s.io/kubernetes at 1.33.4) and fetches advisories by id, at most twice a day per version. No cluster name, namespace, workload, host or address. VULN_DB_URL points it at a self-hosted mirror instead. Details: SECURITY-CHECKS.md.
10 and 11. Relay#
Only with relay.enabled (Helm) / RELAY_URL; without it the agent opens no outbound connection. Operating it: RELAY.md; the wire format: PROTOCOL.md; the decisions behind it: 0005.
App ── HTTPS POST /v1/agents/{agentId}/e2e ──▶ Relay ◀── wss:// (outbound, kept open) ── Agent
0x01 | Noise message 1 │ Call #n: the same bytes ─────────────▶ E2eService.handle()
◀── the agent's answer, unchanged ────────┘ ◀── ReplyEnd #n: status | 0x01 | message 2 | frames- The relay carries channel 1's bytes and nothing else. Requests and answers are sealed between device and agent as on any other path; the relay holds no key that could open them, and an answer it made up does not open in the app.
- What it learns: the agent id (a hash of the agent's public key) and when the agent is online, the IP addresses of the agent and of the calling phone or browser, and the timing and sizes of calls. Not which device calls (the device key travels encrypted), not a path, not a byte of cluster data.
- Registration needs the agent's private key. The relay challenges every connection with a nonce and an ephemeral key; only the holder of the agent's private key can answer, and the public key must hash to the id it claims. A squatter cannot take an agent's place.
- The agent's own checks all still apply: the relay hands the bytes to the same code as
POST /api/e2e(rate limit, replay cache, handshake, clock, device). The relay adds per-agent limits in front (calls per minute, in flight, bytes per hour). - The agent does not trust the relay with its resources: a relay message is at most one request, one challenge per connection, cancels only for calls in flight, a cap on calls in flight and on unread answers. Pairing attempts follow the same rule whether they come through the relay or directly.
- The app learns the relay only from pinned or authenticated sources: the pairing link (only together with the agent key in the same link) or the agent's sealed
/info. It never fetches an agent key through the relay.
12. Native push#
Only when a device taps "Push to this device" in a cluster's settings, and only with a relay that delivers push (NOTIFICATIONS.md, decision 0007). notifications.appPush.enabled: false removes it entirely.
- Sealed per device. The agent seals each message with HPKE for that device's push key (a key pair of its own per cluster, PROTOCOL.md), authenticated with the agent's static key. The relay, Google and Apple carry bytes they cannot read, and a message that does not come from the pinned agent does not open.
- What travels in clear: the device's FCM token, its platform, a key id (a hash of the random push key) and the size and time of each push, for the relay and FCM. The token is stored with the device in
kubernanny-devices, never logged, and goes when the device is revoked or turns push off. - No new connection from the agent: the push rides on the relay WebSocket. The relay talks to
oauth2.googleapis.comandfcm.googleapis.com. - Registration is an ordinary sealed call (
POST /api/push/register); a device registers only itself. - Shape: Android gets data-only messages (no
notificationblock), so the app's own code shows them; iOS always getsmutable-contentwith a placeholder, so the extension replaces it. Every opened push carries the person's marker, which never leaves the phone; a notification without it was sent around Kubernanny by whoever holds the relay's Firebase credentials (NOTIFICATIONS.md).
13. Container registries#
Only while the image-updates module is switched on (Helm imageUpdates.enabled, or the app); it is off by default. At most every 12 hours per image the agent lists the tags of a recognised component's repository (GET /v2/<repository>/tags/list), with an anonymous pull token where the registry asks for one. It sends the repository name and nothing else: not the running tag, no cluster name, namespace, workload or host. Hosts, redirects and guards: SECURITY-CHECKS.md.