controller: ship a FileDB-only image and a gate that proves it runs
build.yml / build_ubuntu (push) Canceled after 0s
build.yml / build_macos (push) Canceled after 0s
build.yml / build_windows (push) Canceled after 0s
Lint / clang-format (push) Canceled after 0s
validate.yml / build_ubuntu (push) Canceled after 0s

ZT_CONTROLLER=1 on a box with libpq present but unconfigured compiles
clean and silently falls back, so a successful build proves nothing.
This adds the embedded controller as a buildable artifact and the check
that would have caught that failure.

ZT_CONTROLLER_NO_SQL=1 gates the SQL block and the smeeclient cargo
target, leaving the ZT_CONTROLLER=1 path byte-identical when unset.
Dropping it removes the arch-pinned ext/*/install/ubuntu22.04 prebuilts
and the rust toolchain from the build, so any Debian base works.

Dockerfile.controller builds that target into a 142MB runtime image.

Three defects surfaced while proving it, all logged in SPEC B8/B9:

- .dockerignore was inert twice over. Its patterns ran as a post-COPY
  RUN printf, which the daemon has already used by then, and bare *.o
  matches the root only under Docker's filepath.Match, so all 121 stale
  objects were copied and linked against the image's glibc 2.36. Now
  **/*.o, which is the known stale-object hazard from AGENTS.md.

- The gate asserted nm -C found nothing inside a runtime image with no
  nm. sh: nm: not found made the pipeline fail, ! inverted it to a pass,
  and the check went green on a missing tool. Uses grep -qaE instead.

- The container ran with -p, so every API call returned 401: OneService
  gates on loopback source at OneService.cpp:1859 unless
  allowManagementFrom widens it, and a DNAT'd port arrives from the
  bridge gateway. The gate uses --network host, and the docs now say so.

Verified: gate passes against the image and in --local, driving network
create, member authorize, member list and the on-disk write. Identity
and controller.d survive container replacement.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
proitlabandClaude Opus 4.8 committed 2026-10-12 06:31:22 +00:00
1 parent ecd6d86be1
commit e5e2990a68
8 files changed
+335 -5

No files matched your search

+29 -2
View File
@@ -1,2 +1,29 @@
.git/
workspace/
# Build outputs. The makefiles emit no -MMD dependency tracking, so shipping the
# checkout's prebuilt .o files into an image build can link an ABI-mismatched
# binary (symptom: SIGSEGV at Topology::Topology on startup). Never copy them.
.git
**/*.o
**/*.a
backone
backone-cli
backone-idtool
backone-selftest
# Arch-pinned vendored prebuilts (ubuntu22.04/amd64, ubuntu22.04/arm64).
# ZT_CONTROLLER_NO_SQL=1 must never link these; excluding them also keeps the
# build context from implying that the image is arch-locked.
ext/libpqxx-7.7.3/install
ext/hiredis-1.0.2/lib
ext/redis-plus-plus-1.3.3/install
rustybits/target
ext/redis-plus-plus-1.3.3/build
ext/hiredis-1.0.2/build
ext/libpqxx-7.7.3/build
# Docs and packaging that no image build reads.
docs
pkg
windows
java
rule-compiler/node_modules
+2 -1
View File
@@ -49,6 +49,7 @@ make selftest && ./backone-selftest
make debug # ZT_DEBUG=1 (adds -g, forces ZT_TRACE=1)
make ZT_SANITIZE=1 one # ASan
make central-controller # ZT_CONTROLLER=1 (needs ext/ libpqxx + hiredis + redis++)
make ZT_CONTROLLER=1 ZT_CONTROLLER_NO_SQL=1 one # embedded controller on FileDB; strips libpqxx/libpq/hiredis/redis++/smeeclient (no cargo, no ext/ prebuilts) — see Dockerfile.controller
make install DESTDIR=/tmp/root
make debian | make redhat # debuild / rpmbuild
make manpages # cd doc && ./build.sh (needs ronn or node marked-man)
@@ -59,7 +60,7 @@ cd tcp-proxy && make
`Makefile` is a uname dispatcher → `make-linux.mk` / `make-mac.mk` / `make-bsd.mk` / `make-netbsd.mk`. Windows: `MSBuild windows/ZeroTierOne.sln /property:Configuration=Release`. Top-level `CMakeLists.txt` is a 323B stub — never `cmake .` as product build.
Env knobs (make vars): `ZT_DEBUG`, `ZT_TRACE`, `ZT_SANITIZE`, `ZT_STATIC`, `ZT_OFFICIAL`, `ZT_CONTROLLER`, `ZT_SSO_SUPPORTED` (0 on Linux default → no cargo needed), `ZT_VAULT_SUPPORT`, `ZT_IA32`.
Env knobs (make vars): `ZT_DEBUG`, `ZT_TRACE`, `ZT_SANITIZE`, `ZT_STATIC`, `ZT_OFFICIAL`, `ZT_CONTROLLER`, `ZT_CONTROLLER_NO_SQL` (opt-out from `ZT_CONTROLLER=1`'s SQL backends; additive, never redefines it), `ZT_SSO_SUPPORTED` (0 on Linux default → no cargo needed), `ZT_VAULT_SUPPORT`, `ZT_IA32`.
**Build hygiene — no header dependency tracking.** The makefiles emit no `-MMD` `.d` files, so `.o` outputs never rebuild when a header changes. A tree that ships prebuilt objects (root `one.o`, `node/*.o`, `libbackonecore.a` — present in this checkout) plus any `.hpp` edit produces ABI-mismatched objects; symptom is an instant `SIGSEGV` at `Topology::Topology` during `./backone` startup with a null call target. `make clean` after touching any `.hpp`, and verify startup after every build:
+61
View File
@@ -0,0 +1,61 @@
# vim: ft=dockerfile
#
# BackOne controller image: embedded controller on FileDB.
#
# ZT_CONTROLLER_NO_SQL=1 keeps PostgreSQL, Redis and the Rust smeeclient client
# out of the build entirely, so no libpq-dev, no cargo toolchain and no
# ext/*/install/ubuntu22.04/$(EXT_ARCH) prebuilts are needed -- any Debian base
# works. See SPEC.md V21/V22.
FROM debian:bookworm-slim AS builder
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
build-essential \
clang \
make \
libssl-dev \
pkg-config \
libminiupnpc-dev \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
RUN make -j"$(nproc)" ZT_CONTROLLER=1 ZT_CONTROLLER_NO_SQL=1 one
# V21: prove at build time that nothing from the SQL backends got in.
RUN ! nm -C backone | grep -qiE 'pqxx|PostgreSQL::|sw::redis|smeeclient'
FROM debian:bookworm-slim
# libminiupnpc is a hard runtime dependency (ldd backone -> libminiupnpc.so.21);
# openssl is required by the gate script's curl usage in CI images and left in
# for operators debugging the control plane. No libpq5, no rust.
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
libminiupnpc17 \
iproute2 \
curl && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /src/backone /usr/sbin/backone
RUN ln -sf /usr/sbin/backone /usr/sbin/backone-cli && \
ln -sf /usr/sbin/backone /usr/sbin/backone-idtool
ENV ZEROTIER_HOME=/var/lib/backone \
ZT_PID_FILE=backone.pid \
ZT_PORT_FILE=backone.port \
ZT_DAEMON=/usr/sbin/backone \
ZT_CLI=backone-cli
# identity.secret + controller.d live here: replacing the container must not
# change the node address or lose network state.
VOLUME ["/var/lib/backone"]
EXPOSE 9993
# -U skips the root check so the container need not run as uid 0, matching the
# spec's "no privilege drop". The daemon runs in the foreground as PID 1.
CMD ["/usr/sbin/backone", "-U", "-p9993"]
+34
View File
@@ -36,6 +36,40 @@ You can build this image like so:
docker build -f Dockerfile.release -t mybuild --build-arg VERSION=1.6.5 .
```
## The controller image (`Dockerfile.controller`)
`Dockerfile.controller` builds BackOne with the embedded network controller enabled and its default `FileDB` backend, with PostgreSQL, Redis and the Rust `smeeclient` library left out of the build entirely. That is what `ZT_CONTROLLER_NO_SQL=1` buys you: no `libpq-dev`, no cargo toolchain, and no `ext/*/install/ubuntu22.04/$(EXT_ARCH)` prebuilts, so the image builds on any Debian base instead of being pinned to the host distribution the vendored prebuilts were cut for.
```
sudo docker build -f Dockerfile.controller -t backone-controller .
sudo docker run -d --name backone-ctl \
--cap-add NET_ADMIN --device /dev/net/tun \
-v backone-ctl:/var/lib/backone \
--network host \
backone-controller /usr/sbin/backone -U -p9993
```
The controller is on by default; there is nothing to configure. Keep `/var/lib/backone` on a volume — it holds `identity.secret` and `controller.d/`, and replacing the container without it changes the node address and loses network state.
`--network host`, not `-p 9993:9993`. The API authorizes loopback source addresses only, unless `settings.allowManagementFrom` widens it (`service/OneService.cpp:1859`), and a published port arrives at the container after DNAT — from the bridge gateway, not loopback — so it answers `401` no matter how correct the token is. Drive the API from inside the container:
```
sudo docker exec backone-ctl sh -c \
'curl -sS -H "X-ZT1-Auth: $(cat /var/lib/backone/authtoken.secret)" http://127.0.0.1:9993/controller/network'
```
To reach the API from another host, bind it to the container's own port with `allowManagementFrom` set to the network you intend to allow, and then treat the token as a credential exposed to that network.
To verify an image rather than trust that it built, run the gate. It asserts the binary carries no PostgreSQL/Redis/smeeclient symbols and then drives a live network create → member authorize → member list → on-disk check through the controller, because a build with an unconfigured SQL backend compiles cleanly and fails only at runtime:
```
tools/controller-image-gate.sh # build the image, then gate it
tools/controller-image-gate.sh --local # gate ./backone without docker
tools/controller-image-gate.sh --image NAME --port N # gate an image already built
```
`make central-controller` and `ZT_CONTROLLER=1` on its own are unchanged: they still build with PostgreSQL and Redis available. `ZT_CONTROLLER_NO_SQL=1` is an opt-out from that, never a redefinition of it.
## Using the docker image
The `entrypoint.sh` in the docker image is a little different; zerotier will be spawned in the background and the "main process" is actually just a sleeping shell script. This allows `zerotier-one` to gracefully terminate in some situations largely unique to docker.
+14 -1
View File
@@ -20,6 +20,11 @@ Make BackOne quantum ready: phases 1-6 of `backone-quantum-fork-research.md` —
- `pqconly` **enforces** a PQ-capable peer on member traffic; `hybrid` only prefers it. Both use the same ML-KEM-768/ML-DSA-65 material (V20, T25)
- wire/identity/COM use versioned v2 + capability-bit fallback to classic
- `include/ZeroTierOne.h` changes additive-only (Java/libzt ripple)
- controller SQL opt-out: `ZT_CONTROLLER_NO_SQL=1` strips `-DZT_CONTROLLER_USE_LIBPQ`, libpqxx/libpq, hiredis, redis++, `libsmeeclient.a`, `-DZT_NO_PEER_METRICS`. `ZT_CONTROLLER=1` keeps meaning (postgres available) so `make central-controller` + `ext/central-controller-docker/` don't break. Flag ⊥ redefine `ZT_CONTROLLER=1` — silent redefinition breaks existing postgres builders, loses the opt-out back
- no-sql build ∉ arch-pinned: no `libpq-dev`, no `ext/*/install/ubuntu22.04/$(EXT_ARCH)` paths, no rust toolchain → any Debian base ok. Vendored prebuilts are `ubuntu22.04`-only amd64+arm64 (V21)
- controller `⊥ OFF` by default: enabled unless `settings.disableController` (`OneService.cpp:1167`); image ! no `local.conf`. `FileDB` = default backend (`controller.d`, `OneService.cpp:907`)
- image: `debian:bookworm-slim` both stages. `CMD` exec daemon PID 1, ⊥ entrypoint wrapper. `VOLUME /var/lib/backone` so `identity.secret` + `controller.d` survive replacement — losing identity → new node address → re-authorize
- build gate ⊥ compile-success-only: postgres-present-unconfigured builds clean + silently falls back (B7 shape). Build ! start container + assert controller API answers
- OUT: AES-256-GCM swap, trusted-path skipCrypto, forward secrecy, protocol standardization, crypto audit, production release/signing
- `?` address v2 derivation keeping 40-bit + PoW
- `?` VL1 fragmentation capacity for +4KB identity (check `node/Packet.*`)
@@ -41,6 +46,7 @@ Make BackOne quantum ready: phases 1-6 of `backone-quantum-fork-research.md` —
| I.pqc.cfg | config | `local.conf` `settings.pqcMode` (off/hybrid/pqconly); **absent = off/classic (opt-in)**, unknown value = warn + classic. `hybrid` prefers PQ and silently falls back; `pqconly` refuses config/credentials from non-capable non-root peers (V20) — a policy mode, not just an identity selector. Per-algorithm `kem`/`sig` selection is *not* wired (research doc only, see T25) |
| I.pqc.wire | wire | static-static hybrid, no ephemeral exchange: identity v2 (type byte 1) stores ML-KEM-768 + ML-DSA-65 pub on disk, but HELLO carries only the classic projection (`Identity::serializeClassic`) so vanilla peers parse it; peer PQ keys arrive in `VERB_PQ_KEYS` (0x17); agree = KDF(X25519-identity-agree ‖ ML-KEM-encaps(peer static pub)); the agreed key is **confirmed** by a trailing 4 B tag in the same verb (optional, V19), since ML-KEM cannot report a mismatched decapsulation; capability via HELLO protocol-version high bit; `identity.secret`/`identity.public` v2 on disk |
| I.pqc.com | credentials | COM double-sign/verify — controller + `node/CertificateOfMembership.*` |
| I.ctlr.img | image | `Dockerfile.controller` — `debian:bookworm-slim` → `make ZT_CONTROLLER=1 ZT_CONTROLLER_NO_SQL=1 one`; runtime stage `openssl` + `iproute2` only, ⊥ `libpq5`/rust. `VOLUME /var/lib/backone`, `CMD ["backone","-U","-p9993"]` |
| I.rules | rules compiler | `node rule-compiler/cli.js <rules>` → rules/tags JSON |
## §V (invariants)
@@ -69,6 +75,8 @@ Derived from `selftest.cpp` + CI gates. `?` = code-derived, no test yet.
| V18 | FLAGS is inside the AES-GMAC-SIV AAD and `dearmor` keeps the FRAGMENTED bit, so `setFragmented(true)` must precede `armor()`; `Switch::_sendViaSpecificPath` may not set it on an already-armored packet. `dearmor` decrypts to scratch and commits only on success, so a failed attempt does not destroy the ciphertext a later key would need. | `selftest.cpp` PQ section: fragmented pre-armed packet dearmors, late-set flag does not (verified `FAIL-AS-EXPECTED`) |
| V19 | The hybrid session key is **confirmed**, never merely assumed. ML-KEM uses implicit rejection: decapsulating with a secret that does not match the peer's public key returns a well-formed but *wrong* shared secret instead of an error, so a peer whose PQ material drifted derived a different key, believed agreement succeeded, and every data frame then failed its MAC — with `_pqKeysAcked` already latched at the first handshake, so the retry timer never fired again and only a one-sided daemon restart recovered. A 4 B tag = `HMAC-SHA384(_key, peer_address)`, under its own KBKDF label (`ZT_KBKDF_LABEL_PQ_CONFIRM '2'`) so it cannot collide with session-key material, rides at the end of `VERB_PQ_KEYS` and is optional on the wire (a build without it still interoperates). Mismatch → `resetPQExchange()`, which reverts `_key` to classical, so the inbound path's hybrid-then-classical fallback (`IncomingPacket.cpp`) keeps working throughout. A peer that rolled its PQ keys still holds ours and therefore sets the ack bit in the very message where the rotation is detected, so that ack is dropped for that exchange — honouring it would re-latch the state just cleared and suppress the reply that carries the fresh ciphertext. | `selftest.cpp` "Key confirmation detects mismatched hybrid key"; direct test against `libbackonecore.a`: honest session confirms, mismatched derivation is caught, renegotiation converges to agreeing keys. Live 2-node hybrid session (n2 joins n1's network) produced zero confirmation failures, so healthy sessions are not reset |
| V20 | `pqconly` is a **policy** mode, not an identity selector. Under `pqconly` a non-capable non-root peer is refused `VERB_NETWORK_CONFIG`, `VERB_NETWORK_CREDENTIALS` **and `VERB_NETWORK_CONFIG_REQUEST`**, so no network comes up over a silently classical link and no COM establishes trust across one; PLANET/MOON roles are exempt because all four Earth roots report `pqcCapable:false` and enforcing against them would cut the node off from the root topology. The third verb is load-bearing and was **measured, not assumed**: gating only the two receive-side verbs left a classical peer able to join, because membership is granted by the *serve* direction — the classic peer asks the pqconly node's controller for its config and the node enforcing the policy was the one handing it over (0% loss, network `OK`, counter incrementing in the unrelated direction). The gate keys on `_hybridCapable` (fixed at HELLO), **not** `hybridSessionKeyInstalled()`, because the encapsulating peer stages its hybrid key until the confirm tag arrives and would otherwise be rejected for the whole staging window. `hybrid` keeps the silent classical fallback but now logs a downgrade `WARNING` once per peer (re-armed on recovery), so a downgraded link is no longer invisible. | `docs/pqconly-mode-test.md` §4a records the hole and the fix; measured 2026-10-08 on the two-host lab: before this change a `pqconly` node held 3 paths to a fully classical peer at 0% loss; after it the classical peer sits at `REQUESTING_CONFIGURATION` with `assignedAddresses:[]` and 100% loss, while two `pqconly` nodes hold 0% loss in both directions with no false rejection. Refusals are countable via `pkt_network_config_in_pqconly_rejected` / `pkt_network_credentials_in_pqconly_rejected` |
| V21 | `ZT_CONTROLLER_NO_SQL=1` → binary ∌ PostgreSQL/Redis/smeeclient symbols, and the embedded controller still runs on `FileDB`. Every symbol `ZT_CONTROLLER=1` adds has `controller/PostgreSQL.cpp` as its sole consumer (verified by grep: libpqxx, hiredis, redis++, `smeeclient` appear nowhere else), and both `PostgreSQL.hpp` and `PostgreSQL.cpp` are wholly wrapped in `#ifdef ZT_CONTROLLER_USE_LIBPQ`, so the file compiles to nothing when the define is absent. `RedisConfig *_rc` (`service/OneService.cpp:900`) and `_controllerDbPath` (`:907`) stay unconditional, so `FileDB` still receives a path. `EmbeddedNetworkController::init` (`controller/EmbeddedNetworkController.cpp:535-541`) falls to `FileDB` when the define is absent. | build: `nm -C backone \| grep -iE "pqxx\|PostgreSQL::\|sw::redis\|smeeclient"` → no matches; container → `GET /controller/network/<id>` returns JSON; binary `-v` matches `version.h` |
| V22 | `ZT_CONTROLLER=1` without `ZT_CONTROLLER_NO_SQL=1` → same link line as before this flag existed. The flag is additive opt-out; ⊥ redefine `ZT_CONTROLLER=1` to mean no-sql. | build: `make ZT_CONTROLLER=1 one` on a box with the `ext/` prebuilts links as it did on 2.0.2; `ext/central-controller-docker/Dockerfile` still valid |
## §T (tasks)
@@ -100,8 +108,11 @@ Derived from `selftest.cpp` + CI gates. `?` = code-derived, no test yet.
| T24 | x | Plumb `settings.pqcMode` through the identity path: `Node(…,int pqcMode)` stores `_pqcMode`; `Identity::generate(bool pq,int pqcMode)` derives `pq` from the daemon mode; `OneService` reads `local.conf` before `new Node` — a fresh hybrid/pqconly node writes a type-1 identity, a classic one type-0. Fixes the G1 defect. | I.pqc.cfg,V12 |
| T25 | . | Distinct PQ parameter sets: `node/PQHybrid.*` hardcodes ML-KEM-768/ML-DSA-65 (`PQHybrid.cpp` static_asserts `OQS_KEM_ml_kem_768`/`OQS_SIG_ml_dsa_65`), so `hybrid` and `pqconly` select identical *cryptographic material*. `pqconly` is nonetheless behaviorally distinct — it enforces the peer requirement (V20) — but §C's "ML-KEM-1024/ML-DSA-87 for `pqconly`" was never implemented and has been removed. Parameterize the preset (key sizes, ct len, `_pendingHybridCt` buffer) only if stronger parameters are actually wanted; the HELLO MTU objection no longer applies (PQ material rides in `VERB_PQ_KEYS`, V17), so the only remaining coupling is the buffer sizes in `Peer.hpp`. | I.pqc.wire,I.pqc.cfg,V15,V17,V20 |
| T26 | . | Expose real PQ state in `/peer`: `pqcCapable`/`pqcHybridActive` are copied from the `ZT_Peer` snapshot, which never populates them, so both always read `false` (B6). Add a `Node` accessor for a live peer by address and populate both fields in the three `_peerToJson` call sites. Needs a `ZT_Node` C API entry point, so it ripples to `include/ZeroTierOne.h`, `java/jni`, and the SDKs — budget for that rather than reaching into `node/` from `service/`. | I.pqc.wire,I.capi,V19 |
| T27 | x | Add `ZT_CONTROLLER_NO_SQL=1` to `make-linux.mk` (and any mac/bsd mirror carrying the same block): when set, suppress `-DZT_CONTROLLER_USE_LIBPQ`, libpqxx/libpq, hiredis, redis++, `libsmeeclient.a`, the `smeeclient` cargo prerequisite, and `-DZT_NO_PEER_METRICS`. Keep the whole `ZT_CONTROLLER=1` block untouched when the flag is unset. Check `objects.mk` for `controller/PostgreSQL.o` — if it links the empty translation unit that is harmless, but confirm the guard (`controller/PostgreSQL.cpp:12-16` … final `#endif`) covers every symbol so `nm` is clean. Verified: `ZT_CONTROLLER=1` flag dump byte-identical to pre-edit (V22); no-sql build has 0 `pqxx|PostgreSQL::|sw::redis|smeeclient` symbols, no `postgres:` string, no libpq/ssl in `ldd`; live daemon created + authorized + listed a member through the FileDB controller (V21). | I.build,V21,V22 |
| T28 | x | Write `Dockerfile.controller`: `debian:bookworm-slim` builder (build-essential clang pkg-config libssl-dev curl) → `make ZT_CONTROLLER=1 ZT_CONTROLLER_NO_SQL=1 one`; runtime stage `bookworm-slim` + `openssl` + `iproute2`, `COPY --from=builder` the binary and `backone-cli`/`backone-idtool` symlinks, `VOLUME /var/lib/backone`, `CMD ["backone","-U","-p9993"]`. ⊥ `entrypoint.sh.release` wrapper. `COPY . .` the tree — `ext/` prebuilts are `ubuntu22.04`-only and must never be referenced (V21). Also required a root `.dockerignore`: the checkout ships 121 stale `.o` built against glibc 2.43, and the image's is 2.36, so `COPY . .` linked host objects and failed with `undefined reference to __isoc23_strtoull`. Patterns must be `**/*.o` — bare `*.o` matches root only and lets `node/Switch.o` through (B8). | I.ctlr.img,V21 |
| T29 | x | Build gate in the Dockerfile: after the build, `docker run` the image, `curl` the controller API, assert real JSON membership — compile success alone proves nothing, since postgres-present-unconfigured builds clean and falls back silently. Ship the gate as a script under `tools/` so it is runnable outside the image too. Shipped as `tools/controller-image-gate.sh` (`--local` / `--image NAME` / `--port N`), asserting: 0 `pqxx|PostgreSQL::|sw::redis|smeeclient` symbols, no libpq/libssl in `ldd`, `/status` `online:true`, controller creates a network, authorizes a member, reads it back, and wrote `controller.d/network/<nwid>.json`. A second assertion lives in the Dockerfile itself (`! nm -C backone \| grep -qiE …`). | I.ctlr.img,I.api,V21 |
T1/T2 = prerequisites — CI must invoke `backone-selftest` before PQC gates mean anything. T1–T16 backlog (rebrand/CI/lint leftovers); T17–T25 = PQC phases 1–6 + the pqconly preset gap; T26 = PQ state is not observable via `/peer`.
T1/T2 = prerequisites — CI must invoke `backone-selftest` before PQC gates mean anything. T1–T16 backlog (rebrand/CI/lint leftovers); T17–T25 = PQC phases 1–6 + the pqconly preset gap; T26 = PQ state is not observable via `/peer`. T27–T29 = controller packaging (`ZT_CONTROLLER_NO_SQL` flag, `Dockerfile.controller`, runtime gate) — independent of the PQC work, sequential inside itself.
Not tracked (low value `?`): `one.cpp:256` port/token cleanup, `MacKextEthernetTap.cpp:480` iface status, VLAN TODOs in `NetBSDEthernetTap.cpp:468`/`MacKextEthernetTap.cpp:685`, `Phy.hpp:325` unix sock type comment.
@@ -116,3 +127,5 @@ Not tracked (low value `?`): `one.cpp:256` port/token cleanup, `MacKextEthernetT
| B5 | 2026-10-07 | A hybrid session could wedge permanently and silently. ML-KEM uses *implicit rejection*: `agreeHybridDecaps` with a secret that does not match the peer's public key returns a well-formed but **wrong** shared secret rather than an error, so both sides believed agreement had succeeded and installed it. A peer whose PQ material drifted (restore from backup, identity roll) derived a different key than its counterpart, and every data frame thereafter failed its MAC. `_pqKeysAcked` had already latched at the first handshake, so `pqKeysDue` never fired again and the retry path could not repair it — recovery required restarting one daemon. Compounding it, a peer that rolled its keys still holds ours and so sets the ack bit in the very message announcing the rotation, so the ack re-latched the state being cleared and suppressed the reply that carried the fresh ciphertext. | Added key confirmation: 4 B `HMAC-SHA384(_key, peer_address)` at the tail of `VERB_PQ_KEYS`, optional on the wire, under its own KBKDF label. Mismatch, or advertised public keys that differ from the installed ones, calls `resetPQExchange()` — drops the hybrid key, reverts `_key` to classical (the inbound hybrid-then-classical fallback keeps traffic alive throughout), re-arms the retry, and re-encapsulates. The stale ack is dropped for that exchange so the reply is not suppressed. `agreeHybridDecaps` failure is no longer silently ignored. Verified in `selftest.cpp` and directly against `libbackonecore.a`; live 2-node hybrid session shows zero false confirmations. |
| B6 | 2026-10-07 | *Reported wrong and withdrawn.* Originally logged as "`pqcCapable`/`pqcHybridActive` in `/peer` are copied from a `ZT_Peer` snapshot that never populates them, so both always report `false`." That was false: `Node::peers()` populates both at `node/Node.cpp:621,626` from `Peer::hybridCapable()` and `Peer::hybridSessionKeyInstalled()`, and no C API change was ever needed — the fields are BackOne additions to `ZT_Peer` itself (`include/ZeroTierOne.h:1460,1467`). What *was* true is narrower and much less interesting: a stale comment at `service/OneService.cpp:621` asserted the snapshot lacked the fields, which contradicted the two lines directly beneath it and would have sent the next reader looking for a missing C API accessor that already existed. The fields were always live. | Deleted the stale comment. No functional change. Verified against a live 2-node hybrid lab: `/peer` reports `pqcHybridActive:true` on both sides once the key is installed, and `false` on a classical peer — the same field `tools/pqc-lab.sh` G4 gates on. Kept here because "the observability does not exist" is an expensive wrong assumption to propagate into the C API surface. |
| B7 | 2026-10-08 | `pqconly` carried a false security assurance: its name, its `Identity.hpp:4` comment ("PQ-only identities, no classic fallback"), and `SPEC` §C all implied that a peer without PQ support would be refused. It refused nothing. The only site distinguishing the modes was identity generation (`Identity.cpp:109`); every runtime gate tested `pqcMode() != ZT_PQC_MODE_CLASSIC` (`Peer.hpp:434`, `Node.cpp:274`), so `hybrid` and `pqconly` shared a code path and a `pqconly` node forwarded packets to a fully classical peer with no warning of any kind. Measured on the two-host lab: a `pqconly` node reported `pqcCapable:false hybrid:false paths=3` against a classical peer and pinged it at 0% loss. An operator selecting `pqconly` for downgrade resistance got neither enforcement nor any signal. | `pqconly` is now enforced rather than merely named: `Peer::pqconlyPeerRejected()` refuses `VERB_NETWORK_CONFIG` and `VERB_NETWORK_CREDENTIALS` from non-capable non-root peers (credentials matters most — a COM is what establishes trust for a network). PLANET/MOON are exempt, because all four Earth roots are `pqcCapable:false` and enforcing against them would sever root topology. The gate keys on `_hybridCapable`, fixed at HELLO, so the encapsulating peer's staged-but-not-yet-installed key does not trigger a false rejection. `hybrid` keeps its fallback but emits a downgrade `WARNING` once per peer, re-armed on recovery. Refusals are counted in `pkt_network_config_in_pqconly_rejected` / `pkt_network_credentials_in_pqconly_rejected`. Verified: `pqcHybridActive` still `true` and 0% loss between two PQ peers; see `docs/pqconly-mode-test.md`. |
| B8 | 2026-10-12 | The first controller image build died at link with `undefined reference to __isoc23_strtoull` in `node/Identity.o`, `node/NetworkConfig.o`, `node/IncomingPacket.o`, `node/InetAddress.o`. Nothing was wrong with `ZT_CONTROLLER_NO_SQL` or the makefile. `Dockerfile.controller` does `COPY . .`, the checkout ships 121 prebuilt `.o` compiled against the host's glibc 2.43, the image is `bookworm-slim` with glibc 2.36 — so the image's linker consumed host objects referencing symbols that only glibc 2.38+ exports. This is the same stale-object hazard `AGENTS.md` already warns about for local builds, arriving through a channel that warning never covered. The first `.dockerignore` did not help, because it was wrong twice over: it carried a post-`COPY` `RUN printf > .dockerignore`, which is dead code (the daemon reads that file before the build stage runs), and its `*.o` / `*.a` patterns match the **root only** under Docker's `filepath.Match` semantics, so 121 of 121 objects were still copied. A green build was never reachable from this tree. | Root `.dockerignore` with `**/*.o` and `**/*.a`, so `node/Switch.o` and `ext/liboqs/**` are both excluded; plus the arch-pinned `ext/*/install` prebuilts and the three `ext/*/build` trees. Verified: the rebuilt image links clean from an empty context and the daemon in it serves the controller (T28, T29). |
| B9 | 2026-10-12 | The gate passed checks it never performed. Three defects, each a false green rather than a false red. (a) The image-symbol check ran `nm -C /usr/sbin/backone \| grep -qi …` inside the runtime image, which ships no `nm` — `sh: nm: not found` made the pipeline exit non-zero, `! …` invert it to success, and the check reported a clean binary while proving nothing. (b) `--image NAME` was documented as "test an existing image" but branched into `docker build`, so there was no way to gate a prebuilt image without rebuilding it. (c) The container ran with `-p 127.0.0.1:$PORT:9993`, and every API call returned `401` with body `{}`: the auth gate at `OneService.cpp:1859-1905` admits `IP_SCOPE_LOOPBACK` or a match in `settings.allowManagementFrom`, and a DNAT'd published port arrives sourced from the bridge gateway, which is neither. The gate then spent 30s waiting for an `online:true` that could never arrive. | (a) Replaced with `grep -qaE` on the binary, which the image does have, and it fails loudly rather than on a missing tool; the image was independently confirmed to have no `nm`/`strings`/`readelf` at all. (b) `--image` now skips the build, as its help text always claimed. (c) Gate container runs `--network host` so the request stays on loopback, matching the posture operators actually get; README.docker.md now says `--network host`, not `-p 9993:9993`, and explains the `allowManagementFrom` route for reaching the API off-host. Verified: gate PASSes on the built image and in `--local` mode, driving create → authorize → list → on-disk write. |
+11
View File
@@ -342,6 +342,12 @@ endif
ifeq ($(ZT_CONTROLLER),1)
override CXXFLAGS+=-Wall -Wno-deprecated -std=c++17 -pthread $(INCLUDES) -DNDEBUG $(DEFS)
ifeq ($(ZT_CONTROLLER_NO_SQL),1)
# Embedded controller on FileDB only: no PostgreSQL, Redis or smeeclient.
# controller/PostgreSQL.cpp is wholly #ifdef ZT_CONTROLLER_USE_LIBPQ, so it
# compiles to an empty translation unit and FileDB is selected by absence of
# the define (controller/EmbeddedNetworkController.cpp).
else
override LDLIBS+=-Lext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/lib -lpqxx -lpq ext/hiredis-1.0.2/lib/ubuntu22.04/$(EXT_ARCH)/libhiredis.a ext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/lib/libredis++.a -lssl -lcrypto
override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_NO_PEER_METRICS
override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include/sw/
@@ -351,6 +357,7 @@ ifeq ($(ZT_CONTROLLER),1)
override LDLIBS+=rustybits/target/release/libsmeeclient.a
endif
endif
endif
# ARM32 hell -- use conservative CFLAGS
ifeq ($(ZT_ARCHITECTURE),3)
@@ -467,8 +474,12 @@ zeroidc:
endif
ifeq ($(ZT_CONTROLLER), 1)
ifeq ($(ZT_CONTROLLER_NO_SQL),1)
smeeclient:
else
smeeclient: FORCE
export PATH=$$HOME/.cargo/bin:$$PATH; cd rustybits && cargo build $(ZT_CARGO_FLAGS) -p smeeclient
endif
else
smeeclient:
endif
+1 -1
View File
@@ -38,7 +38,7 @@ Settings available in `local.conf` (this is not valid JSON, and JSON does not al
"softwareUpdateChannel": "release"|"beta", /* Software update channel */
"softwareUpdateDist": true|false, /* If true, distribute software updates (only really useful to ZeroTier, Inc. itself, default is false) */
"interfacePrefixBlacklist": [ "XXX",... ], /* Array of interface name prefixes (e.g. eth for eth#) to blacklist for ZT traffic */
"allowManagementFrom": [ "NETWORK/bits", ...] |null, /* If non-NULL, allow JSON/HTTP management from this IP network. Default is 127.0.0.1 only. */
"allowManagementFrom": [ "NETWORK/bits", ...] |null, /* If non-NULL, allow JSON/HTTP management from this IP network. Default is 127.0.0.1 only. Enforced at service/OneService.cpp:1859: a non-loopback source is refused with 401 and body `{}` *before* the auth token is compared, so publishing the port through a container, port-forward or NAT edge grants no access. Widen this and the token becomes a credential exposed to that network. */
"bind": [ "ip",... ], /* If present and non-null, bind to these IPs instead of to each interface (wildcard IP allowed) */
"allowTcpFallbackRelay": true|false, /* Allow or disallow establishment of TCP relay connections (true by default) */
"multipathMode": 0|1|2, /* multipath mode: none (0), random (1), proportional (2) */
+183
View File
@@ -0,0 +1,183 @@
#!/usr/bin/env bash
# Gate for the controller image: prove the embedded controller is live on
# FileDB, not merely linked.
#
# Compile success is not evidence. `ZT_CONTROLLER=1` on a box with libpq
# present but unconfigured builds cleanly and silently falls back, which is
# exactly the failure this gate exists to catch (SPEC.md V21, §C).
#
# Usage:
# tools/controller-image-gate.sh # docker: build image + run
# tools/controller-image-gate.sh --local # test ./backone directly
# tools/controller-image-gate.sh --image NAME # test an existing image
set -uo pipefail
MODE=docker
IMAGE=backone-controller
PORT=19993
NWID=8056c5e10c000000
while [[ $# -gt 0 ]]; do
case "$1" in
--local) MODE=local; shift ;;
--image) MODE=image; IMAGE="$2"; shift 2 ;;
--port) PORT="$2"; shift 2 ;;
*) echo "unknown arg: $1" >&2; exit 2 ;;
esac
done
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
fail=0
ok() { echo " ok $*"; }
bad() { echo " FAIL $*"; fail=1; }
say() { echo; echo "== $*"; }
CURL=(curl -sS --max-time 10)
# ---------------------------------------------------------------- local mode
if [[ "$MODE" == local ]]; then
BIN="$ROOT/backone"
[[ -x "$BIN" ]] || { echo "no ./backone -- run: make ZT_CONTROLLER=1 ZT_CONTROLLER_NO_SQL=1 one" >&2; exit 2; }
HOMEDIR="$(mktemp -d /tmp/bo-gate.XXXXXX)"
CID=""
trap '[[ -n "$CID" ]] && kill "$CID" 2>/dev/null; rm -rf "$HOMEDIR"' EXIT
say "V21: binary carries no SQL backend symbols"
if nm -C "$BIN" 2>/dev/null | grep -qiE 'pqxx|PostgreSQL::|sw::redis|smeeclient'; then
bad "found PostgreSQL/Redis/smeeclient symbols in $BIN"
else
ok "no pqxx / PostgreSQL:: / sw::redis / smeeclient symbols"
fi
if ldd "$BIN" | grep -qiE 'libpq|libssl|libcrypto'; then
bad "binary dynamically links libpq/libssl/libcrypto"
else
ok "no libpq/libssl/libcrypto in ldd"
fi
say "controller answers on FileDB"
"$BIN" -p"$PORT" -U "$HOMEDIR" >"$HOMEDIR/log" 2>&1 &
CID=$!
else
# ------------------------------------------------------------ docker mode
if [[ "$MODE" == image ]]; then
say "using existing image $IMAGE"
else
say "building image $IMAGE from Dockerfile.controller"
# shellcheck disable=SC2086
sudo -n docker build -f "$ROOT/Dockerfile.controller" -t "$IMAGE" "$ROOT" || exit 2
fi
say "V21: binary carries no SQL backend symbols"
# The runtime image is intentionally minimal and has no nm/strings, so
# asserting "nm -C ... found nothing" there would pass even if the tool
# were simply absent. Test with the tool that exists, and let a missing
# tool fail rather than pass.
if sudo -n docker run --rm --entrypoint sh "$IMAGE" -c \
"! grep -qaE 'pqxx|PostgreSQL__|sw__redis|smeeclient' /usr/sbin/backone"; then
ok "no pqxx / PostgreSQL / sw::redis / smeeclient strings in image binary"
else
bad "SQL backend strings present in image binary"
fi
say "controller answers on FileDB"
NAME="bo-gate-$$"
# --network host, not -p: the API authorizes loopback only unless
# settings.allowManagementFrom widens it (OneService.cpp:1859-1905), and a
# published port DNATs, so the request arrives from the bridge gateway and
# gets 401 no matter how correct the token is. Host networking keeps the
# request on loopback and exercises the posture operators actually get.
sudo -n docker run -d --name "$NAME" --network host \
-v "$NAME:/var/lib/backone" \
"$IMAGE" /usr/sbin/backone -U -p"$PORT" >/dev/null || exit 2
trap 'sudo -n docker rm -f "$NAME" >/dev/null 2>&1; sudo -n docker volume rm -f "$NAME" >/dev/null 2>&1' EXIT
fi
# ------------------------------------------------------------------- shared
API="http://127.0.0.1:$PORT"
TOKEN=""
for _ in $(seq 1 30); do
if [[ "$MODE" == local ]]; then
[[ -s "$HOMEDIR/authtoken.secret" ]] && { TOKEN="$(cat "$HOMEDIR/authtoken.secret")"; break; }
else
TOKEN="$(sudo -n docker exec "$NAME" cat /var/lib/backone/authtoken.secret 2>/dev/null)" && [[ -n "$TOKEN" ]] && break
fi
sleep 1
done
if [[ -z "$TOKEN" ]]; then
bad "daemon never produced an auth token (see logs)"
[[ "$MODE" == local ]] && cat "$HOMEDIR/log"
[[ "$MODE" != local ]] && sudo -n docker logs "$NAME" 2>&1 | tail -20
exit 1
fi
ok "daemon up, control plane listening on $PORT"
# The token is written before the control plane finishes binding, and the API
# can answer /status a moment before the node reports itself online, so wait
# for the online field rather than sleeping a fixed amount.
STATUS=""
for _ in $(seq 1 30); do
STATUS="$("${CURL[@]}" -H "X-ZT1-Auth: $TOKEN" "$API/status" 2>/dev/null)"
echo "$STATUS" | grep -q '"online":true' && break
sleep 1
done
if ! echo "$STATUS" | grep -q '"online":true'; then
bad "node never reported online:true -- got: ${STATUS:0:200}"
[[ "$MODE" == local ]] && tail -20 "$HOMEDIR/log"
[[ "$MODE" != local ]] && sudo -n docker logs "$NAME" 2>&1 | tail -20
exit 1
fi
ok "control plane answered /status with online:true"
# create a network: proves the controller, not just the API server.
CREATE="$("${CURL[@]}" -H "X-ZT1-Auth: $TOKEN" -X POST \
-d '{"name":"gate","private":true}' "$API/controller/network/$NWID" 2>/dev/null)"
if echo "$CREATE" | grep -q '"id":"'"$NWID"'"'; then
ok "controller created network $NWID"
else
bad "controller did not create network $NWID -- got: ${CREATE:0:200}"
bad "a controller that is absent or on an unconfigured backend answers exactly like this"
exit 1
fi
# authorize a member: proves the write path through the DB.
PUB="$(echo "$STATUS" | sed -n 's/.*"publicIdentity":"\([^"]*\)".*/\1/p')"
MID="${PUB%%:*}"
if [[ -n "$MID" && ${#MID} -eq 10 ]]; then
AUTH="$("${CURL[@]}" -H "X-ZT1-Auth: $TOKEN" -X POST \
-d "{\"authorized\":true,\"identity\":\"$PUB\"}" \
"$API/controller/network/$NWID/member/$MID" 2>/dev/null)"
if echo "$AUTH" | grep -q '"authorized":true'; then
ok "controller authorized member $MID"
else
bad "member authorize failed -- got: ${AUTH:0:200}"
fi
LIST="$("${CURL[@]}" -H "X-ZT1-Auth: $TOKEN" "$API/controller/network/$NWID/member" 2>/dev/null)"
if echo "$LIST" | grep -q "$MID"; then
ok "member $MID reads back from the member list"
else
bad "member list did not contain $MID -- got: ${LIST:0:200}"
fi
else
bad "could not derive a 10-hex member id from /status publicIdentity"
fi
# state must be on disk, not just in memory.
if [[ "$MODE" == local ]]; then
NFILE="$HOMEDIR/controller.d/network/$NWID.json"
[[ -f "$NFILE" ]] && ok "FileDB wrote $NFILE" || bad "no FileDB network file at $NFILE"
else
if sudo -n docker exec "$NAME" test -f "/var/lib/backone/controller.d/network/$NWID.json"; then
ok "FileDB wrote controller.d/network/$NWID.json"
else
bad "no FileDB network file in the container"
fi
fi
echo
if [[ $fail -eq 0 ]]; then
echo "PASS: controller live on FileDB, no SQL backend linked"
exit 0
fi
echo "FAIL: see above"
exit 1