| 1 | # Security |
| 2 | |
| 3 | celld is an alpha. It is not safe for hostile multi-tenant use. Security fixes |
| 4 | apply to the latest release only, so older alpha builds do not receive fixes. |
| 5 | |
| 6 | ## Separate the public and internal listeners |
| 7 | |
| 8 | celld opens two HTTP listeners. The public listener serves the deployed Worker, |
| 9 | and the internal listener serves the peer protocol and the operator API. |
| 10 | |
| 11 | Use `--listen` for the public listener. Expose only this listener through a load |
| 12 | balancer, a reverse proxy, or a public firewall rule. |
| 13 | |
| 14 | Use `--internal-listen` for the internal listener. Its default address is |
| 15 | `127.0.0.1:0`, so celld selects an available loopback port at each start. |
| 16 | The startup output reports the selected address. |
| 17 | |
| 18 | Use `--advertise` to give peers the address of the internal listener. Bind the |
| 19 | internal listener to a private interface, or protect it with a private overlay. |
| 20 | Do not expose this listener to the public internet. |
| 21 | |
| 22 | An explicit advertised address requires an explicit internal-listener address. |
| 23 | Set both command-line options, or use their equivalent environment variables. |
| 24 | celld also rejects an explicit non-loopback public listener without an explicit |
| 25 | internal listener. This rule identifies an obsolete one-listener configuration. |
| 26 | |
| 27 | celld cannot verify that an advertised hostname or a translated port reaches |
| 28 | the internal listener. You must route the advertised address to the internal |
| 29 | listener, and you must not route it to the public Worker listener. |
| 30 | |
| 31 | The public listener reserves only `/__celld/health`. A healthy node returns a |
| 32 | 200 response with `{"ok":true}`, and an unhealthy node returns a 503 response. |
| 33 | The deployed Worker owns `/health` and every other public path. |
| 34 | |
| 35 | The internal listener does not pass an unknown path to the Worker. It returns a |
| 36 | 404 response, so an operator request cannot become an application request. |
| 37 | |
| 38 | ## Set the forwarded-header policy |
| 39 | |
| 40 | A Worker reads the request URL from `request.url`. An application can route on |
| 41 | the hostname and build an absolute link from this URL. Therefore, celld ignores |
| 42 | `X-Forwarded-Host` and `X-Forwarded-Proto` by default. |
| 43 | |
| 44 | Set `--trust-forwarded-headers` only when a trusted proxy replaces both headers. |
| 45 | celld then reads the last value in each header, so an earlier client value does |
| 46 | not override the proxy value. The equivalent environment variable is |
| 47 | `CELLD_TRUST_FORWARDED_HEADERS=1`. |
| 48 | |
| 49 | celld always takes the path and query from the request target. It ignores an |
| 50 | absolute-form request target's scheme and authority, so a direct client cannot |
| 51 | bypass the host policy through the request line. |
| 52 | |
| 53 | ## Protect the internal listener |
| 54 | |
| 55 | The operator API does not authenticate its requests. A client that can reach |
| 56 | the internal listener can inspect state, start direct work, evict a cell, or |
| 57 | stop the process. Therefore, a firewall or a private overlay must restrict |
| 58 | access to trusted operators and fleet nodes. |
| 59 | |
| 60 | Peer requests on the same listener keep their protocol authentication. Each |
| 61 | peer request has an HMAC, a body signature, a clock limit, and replay |
| 62 | protection. The private network adds protection, but it does not replace the |
| 63 | peer authentication. |
| 64 | |
| 65 | celld does not terminate TLS on the internal listener. Use an encrypted overlay |
| 66 | such as WireGuard or Tailscale when the private network does not provide the |
| 67 | required confidentiality. |
| 68 | |
| 69 | ## Internal operator API |
| 70 | |
| 71 | The internal operator API is available in the released binary. The API is an |
| 72 | alpha interface, so a release can change its paths or response formats. |
| 73 | |
| 74 | - `/state` reports the current occupancy, eviction, and restoration values. It |
| 75 | remains available while a graceful shutdown drains existing work. |
| 76 | - `/cell/NAME` resolves or activates a cell for an operator check. |
| 77 | - `/evict/NAME` evicts a resident cell. |
| 78 | - `/do/NAME` sends a direct Durable Object request. |
| 79 | - `POST /shutdown` starts a graceful ownership handoff. |
| 80 | - `POST /shutdown?handoff=preserve` prepares a clean same-node reload and keeps |
| 81 | the ownership records. |
| 82 | - `/__celld/probe` serves the signed diagnostic probe. |
| 83 | |
| 84 | The peer protocol also uses reserved internal paths. An operator must not call |
| 85 | these paths directly, and celld continues to authenticate each peer request. |
| 86 | |
| 87 | ## Protect the fleet bucket |
| 88 | |
| 89 | The fleet bucket is the root of authority for the fleet. It stores the |
| 90 | deployments, the cell state, the ownership leases, the node leases, and the |
| 91 | shared peer-authentication secret. |
| 92 | |
| 93 | A person who holds the bucket credentials controls the fleet. Give each |
| 94 | credential access to one fleet bucket only, and replace a credential after a |
| 95 | suspected disclosure. |
| 96 | |
| 97 | ## Keep one writer for each cell |
| 98 | |
| 99 | Each cell is a SQLite database with one writer. One node owns a cell at a time, |
| 100 | and an ownership epoch fences each cell. |
| 101 | |
| 102 | A node that loses its lease cannot modify the current cell state. The |
| 103 | [ownership and fencing](fencing.md) page describes this mechanism. |
| 104 | |
| 105 | A fleet has no shared multi-tenant scheduler or shared placement layer. A |
| 106 | defective cell can access only its own database, but it can consume resources |
| 107 | on its fleet nodes. |
| 108 | |
| 109 | ## Protect the public application |
| 110 | |
| 111 | celld does not authenticate the users of the deployed application. It also does |
| 112 | not terminate public TLS. Put the required authentication and TLS in front of |
| 113 | the public listener. |
| 114 | |
| 115 | Keep the internal listener private, and keep the bucket credentials secret. |
| 116 | See the [limitations](limitations.md) page for the complete alpha boundary. |