Diffinery

homeflare/celldpublic

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