Compare commits
7
Commits
v2.0.2-pqc
..
v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdcb1224cc | ||
|
|
6c23665072 | ||
|
|
e5e2990a68 | ||
|
|
ecd6d86be1 | ||
|
|
2e2b0910a8 | ||
|
|
975148525b | ||
|
|
727e31b33d |
No files matched your search
+29
-2
@@ -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
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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"]
|
||||
@@ -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.
|
||||
|
||||
@@ -1,6 +1,75 @@
|
||||
ZeroTier Release Notes
|
||||
======
|
||||
|
||||
# 2026-12-04 -- Version 2.0.4
|
||||
|
||||
* Fix: a `pqcMode:hybrid` controller refused every pre-PQ (v1.x) client.
|
||||
The controller always double-signed the certificate of membership, so it
|
||||
serialized with type byte 2, and a v1 parser rejects any type != 1: the
|
||||
whole network config was dropped and the client sat at
|
||||
`REQUESTING_CONFIGURATION` forever, surfacing as `ACCESS_DENIED` once the
|
||||
network was private.
|
||||
|
||||
The requester's PQ capability now rides in the `VERB_NETWORK_CONFIG_REQUEST`
|
||||
metadata (`ZT_NETWORKCONFIG_REQUEST_METADATA_FLAG_PQ_CAPABLE`, bit 0 of the
|
||||
previously-unused `f` key). A type-2 COM goes only to a requester that
|
||||
advertised the bit; everyone else -- every legacy client, and push configs
|
||||
that carry no request metadata -- gets type 1. No wire change for v1 peers
|
||||
beyond the metadata key they already ignore.
|
||||
|
||||
* Verified on the lab: legacy v1.14.1 client `status:OK`,
|
||||
`netconfRevision:5` against a `hybrid` controller (was
|
||||
`REQUESTING_CONFIGURATION`, revision 0); a 2.0.3 hybrid client still comes
|
||||
up `OK` and still receives type 2. selftest exit 0, no failures.
|
||||
|
||||
# 2026-10-08 -- Version 2.0.3
|
||||
|
||||
* Fix: `pqconly` enforced nothing. The mode selected a type-1 identity, then
|
||||
every handshake gate tested only `pqcMode() != CLASSIC` -- identical to
|
||||
`hybrid` -- so it distinguished nothing and refused no peer. A node in
|
||||
`pqconly` carried traffic with a fully classical peer at 0% loss, with no
|
||||
log line and no way to detect it except reading `pqcHybridActive`.
|
||||
|
||||
`pqconly` is now a policy. A non-capable, non-root peer is refused
|
||||
`VERB_NETWORK_CONFIG`, `VERB_NETWORK_CREDENTIALS` and
|
||||
`VERB_NETWORK_CONFIG_REQUEST`, each counted, with a one-time WARNING per
|
||||
peer. PLANET/MOON are exempt: all four Earth roots report
|
||||
`pqcCapable:false` and enforcing against them would cut the node off from
|
||||
the root topology. Peering itself is still allowed -- what is refused is the
|
||||
network coming up over a link that cannot be PQ-protected.
|
||||
|
||||
* Fix: the first version of that gate still let a classical peer join, because
|
||||
membership is granted by the *serve* direction. A classic peer asks the
|
||||
`pqconly` node's controller for its config, and the node enforcing the
|
||||
policy was the one handing it over; the two receive-side gates could not see
|
||||
it. The counter was incrementing in the unrelated direction the whole time,
|
||||
which is what made the false assurance look like a pass.
|
||||
|
||||
* Add: `hybrid` keeps its silent classical fallback -- that is its contract --
|
||||
but now logs a downgrade WARNING once per peer, re-armed on recovery, so a
|
||||
downgraded link is no longer invisible.
|
||||
|
||||
* Add: `/peer` reports real `pqcCapable` / `pqcHybridActive` per peer, taken
|
||||
from `Node::peers()` rather than copied from the `ZT_Peer` snapshot, which
|
||||
never populated them and so always read `false`.
|
||||
|
||||
* The gate keys on `_hybridCapable`, not `hybridSessionKeyInstalled()`: the
|
||||
encapsulating peer stages its hybrid key until the confirm tag arrives, so
|
||||
gating on the installed key would reject a healthy PQ peer for the whole
|
||||
staging window.
|
||||
|
||||
* Verified on a two-host lab, clean rebuild, selftest exit 0: `pqconly` versus
|
||||
a classical peer now sits at `REQUESTING_CONFIGURATION` with no assigned
|
||||
address and 100% loss (was `OK` at 0% loss); two `pqconly` nodes hold 0% loss
|
||||
in both directions with no false rejection.
|
||||
|
||||
* Note: `_hybridCapable` is latched at HELLO and not cleared. A peer that
|
||||
downgrades without restarting keeps its stale bit until its next HELLO. Not
|
||||
currently exploitable -- capability is re-advertised every HELLO and the mode
|
||||
only ever refuses non-capable peers -- but a peer that restarts into a
|
||||
classical identity with the same home path will be refused until its
|
||||
controller path is re-negotiated.
|
||||
|
||||
# 2026-10-07 -- Version 2.0.2
|
||||
|
||||
* Fix: post-quantum hybrid handshakes never completed. A peer's identity is
|
||||
|
||||
@@ -16,9 +16,15 @@ Make BackOne quantum ready: phases 1-6 of `backone-quantum-fork-research.md` —
|
||||
- New compiled file → register in `objects.mk` or no link.
|
||||
- Platforms: Linux (primary), macOS, BSD/NetBSD, Windows (msbuild).
|
||||
- Header edits: no `-MMD` dep tracking → `make clean` after touching `.h`.
|
||||
- PQC lock: liboqs static vendored `ext/`; hybrid key = KDF(classical ‖ pq); presets `hybrid` (ML-KEM-768/ML-DSA-65) + `pqconly` (intended ML-KEM-1024/ML-DSA-87 — not yet distinct, see T25)
|
||||
- PQC lock: liboqs static vendored `ext/`; hybrid key = KDF(classical ‖ pq); presets `hybrid` (ML-KEM-768/ML-DSA-65) + `pqconly` (same parameter set as `hybrid` — not distinct, see T25)
|
||||
- `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.*`)
|
||||
@@ -37,9 +43,10 @@ Make BackOne quantum ready: phases 1-6 of `backone-quantum-fork-research.md` —
|
||||
| I.build | build | `make`, `make one`, `make selftest`, `make core`, `make debug`, `make install`, `make debian/redhat`, `make central-controller`; env `ZT_*` knobs |
|
||||
| I.ffi | Rust FFI | `rustybits/zeroidc` (`zeroidc_new`…), `smeeclient` — C header `zeroidc.h`, link on `ZT_SSO_SUPPORTED=1`/`ZT_CONTROLLER=1` |
|
||||
| I.jni | Java SDK | `java/jni/…Node.cpp`, ant targets `build_java/build_android/build_jar` |
|
||||
| I.pqc.cfg | config | `local.conf` `settings.pqcMode` (off/hybrid/pqconly); **absent = off/classic (opt-in)**, unknown value = warn + classic. Per-algorithm `kem`/`sig` selection is *not* wired (research doc only, see T25) |
|
||||
| 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)
|
||||
@@ -67,6 +74,10 @@ Derived from `selftest.cpp` + CI gates. `?` = code-derived, no test yet.
|
||||
| V17 | PQ public keys travel out of band in `VERB_PQ_KEYS` (0x17), never inside HELLO: HELLO carries only `Identity::serializeClassic` so a vanilla peer can parse it, and `VERB_PQ_KEYS` (4253 B → 3 frags) carries ML-KEM-768 + ML-DSA-65 public keys plus, from the lowest address, the 1088 B ct. Flag byte: bit0 = ct present, bit1 = "I already hold your keys" (ends the retry loop). A 4 B key-confirmation tag follows the keys (after the ct when present), see V19. | 2-node moon lab: `pqcCapable:true`, `pqcHybridActive:true`, 3 active direct paths at 172.31.0.1/19993 (2026-10-06) |
|
||||
| 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 |
|
||||
| V23 | A pre-PQ peer must reach `OK` against a `hybrid` controller. The controller issues a classic type-1 COM to any requester whose `VERB_NETWORK_CONFIG_REQUEST` metadata flags omit `ZT_NETWORKCONFIG_REQUEST_METADATA_FLAG_PQ_CAPABLE`; type 2 goes only to a requester that advertised the bit. Push configs (`requestPacketId == 0xffff...`, no requester metadata) also get type 1. | `controller/EmbeddedNetworkController.cpp:2039-2045`, `node/CertificateOfMembership.cpp:97,110-113`, `node/Network.cpp:1314`, `node/NetworkConfig.hpp:135-139`, `selftest.cpp:812` |
|
||||
|
||||
## §T (tasks)
|
||||
|
||||
@@ -96,10 +107,13 @@ Derived from `selftest.cpp` + CI gates. `?` = code-derived, no test yet.
|
||||
| T22 | x | Phase 6: selftest extension — ML-KEM/ML-DSA KATs, hybrid KDF vector, identity v2 roundtrip + address stability, COM double-sign, interop hybrid↔vanilla matrix | I.build,V11,V10,V14 |
|
||||
| T23 | x | Phase 6: handshake-vs-fragment-loss benchmark for PQC HELLO; cap/segment if loss breaks handshake | V15 |
|
||||
| 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` currently select identical material, while `SPEC` §C claims ML-KEM-1024/ML-DSA-87 for `pqconly`. Parameterize the preset (key sizes, ct len, `_pendingHybridCt` buffer) or drop the `pqconly` claim. The HELLO MTU objection recorded here 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 |
|
||||
| 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.
|
||||
|
||||
@@ -113,3 +127,7 @@ Not tracked (low value `?`): `one.cpp:256` port/token cleanup, `MacKextEthernetT
|
||||
| B4 | 2026-10-06 | Reported symptom was `backone-cli peers` showing a wall of `PLANET -1 RELAY` rows. Two things were wrong with the reading: the leading `200` is the HTTP status code that `one.cpp:453` prints, not a peer count; and the rows are the four hardcoded Earth roots, which a host with no UDP egress to `9993.zerotier.com` can never reach — hence `RELAY` and latency `-1` with no path. | No code change. Documented here so the symptom is not re-read as a PQ failure: a node that cannot reach a root shows exactly this table, independent of `pqcMode`. |
|
||||
| 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. |
|
||||
| B10 | 2026-12-04 | `pqcMode:hybrid` controller refused every legacy (v1.14.1) client: it always double-signed the COM, so the credential serialized with type byte 2, and the legacy `CertificateOfMembership::deserialize` throws `INVALID_SERIALIZED_DATA_INVALID_TYPE` on any byte != 1. `NetworkConfig::fromDictionary` then threw, `Network::handleConfigChunk` caught and dropped the chunk, and the client sat at `REQUESTING_CONFIGURATION` forever, surfacing as `ACCESS_DENIED` once the network was private and its member unapproved. Measured on the lab pair: controller `tx network_config` ≈3 per join with 1432+1432+1106-byte chunks arriving at the client (tcpdump), client `netconfRevision:0`, `status:REQUESTING_CONFIGURATION`; the same client against a classic-mode controller came up immediately. Nothing in the request path exposed the requester's capability to the controller, so the wire form could not be chosen per requester. | `node/NetworkConfig.hpp:135-139` adds `ZT_NETWORKCONFIG_REQUEST_METADATA_FLAG_PQ_CAPABLE` (bit 0 of the existing `f` metadata key, previously hardcoded 0); `node/Network.cpp:1314` sets it when `pqcMode != classic`; `CertificateOfMembership::sign` takes `pqSign` and skips the ML-DSA half when false; the controller reads the flag and passes it. Non-flagging requesters — every legacy client, and push configs that carry no request metadata — get type 1. Verified: legacy client `status:OK`, `netconfRevision:5` against a `hybrid` controller; `selftest.cpp` `[certificate] PQ authority can issue classic COM on demand... PASS` |
|
||||
+14
-1
@@ -1,5 +1,5 @@
|
||||
Name: backone
|
||||
Version: 2.0.2
|
||||
Version: 2.0.4
|
||||
Release: 1%{?dist}
|
||||
Summary: BackOne global ethernet switch
|
||||
|
||||
@@ -155,6 +155,19 @@ chmod 0755 $RPM_BUILD_ROOT/etc/init.d/backone
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Dec 4 2026 Dedy Sutanto <dsutanto@backone.cloud> - 2.0.4
|
||||
- Fix: a pqcMode:hybrid controller refused every legacy client. COM was always
|
||||
double-signed, so it serialized with type byte 2, and a pre-PQ parser rejects
|
||||
any type != 1, dropping the whole network config. The requester's PQ
|
||||
capability now rides in the network-config-request metadata and the
|
||||
controller issues type 1 to a requester that did not advertise it.
|
||||
See RELEASE-NOTES.md.
|
||||
|
||||
* Thu Oct 8 2026 Dedy Sutanto <dsutanto@backone.cloud> - 2.0.3
|
||||
- pqconly now enforces a PQ-capable peer on member traffic, including on the
|
||||
config-serve path. Previously it enforced nothing and behaved identically to
|
||||
hybrid. See RELEASE-NOTES.md.
|
||||
|
||||
* Wed Oct 7 2026 Dedy Sutanto <dsutanto@backone.cloud> - 2.0.2
|
||||
- see https://github.com/proitlab/BackOne for release notes
|
||||
|
||||
|
||||
@@ -2036,8 +2036,13 @@ void EmbeddedNetworkController::_request(
|
||||
nc->certificateOfOwnershipCount = 1;
|
||||
}
|
||||
|
||||
// A requester that did not advertise PQ capability cannot parse COM type 2
|
||||
// (its COM parser rejects any type byte != 1 and drops the whole netconf, so
|
||||
// it never leaves REQUESTING_CONFIGURATION and ends at ACCESS_DENIED).
|
||||
// Issue it a classic type-1 COM instead.
|
||||
const bool requesterPQCapable = ((metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS,0) & ZT_NETWORKCONFIG_REQUEST_METADATA_FLAG_PQ_CAPABLE) != 0);
|
||||
CertificateOfMembership com(now,credentialtmd,nwid,identity);
|
||||
if (com.sign(_signingId)) {
|
||||
if (com.sign(_signingId,requesterPQCapable)) {
|
||||
nc->com = com;
|
||||
} else {
|
||||
_sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_INTERNAL_SERVER_ERROR, nullptr, 0);
|
||||
|
||||
Vendored
+19
@@ -1,3 +1,22 @@
|
||||
backone (2.0.4) unstable; urgency=medium
|
||||
|
||||
* Fix: a pqcMode:hybrid controller refused every legacy client. COM was
|
||||
always double-signed, so it serialized with type byte 2, and a pre-PQ parser
|
||||
rejects any type != 1, dropping the whole network config. The requester's PQ
|
||||
capability now rides in the network-config-request metadata and the
|
||||
controller issues type 1 to a requester that did not advertise it. See
|
||||
RELEASE-NOTES.md.
|
||||
|
||||
-- Dedy Sutanto <dsutanto@backone.cloud> Fri, 04 Dec 2026 00:00:00 +0700
|
||||
|
||||
backone (2.0.3) unstable; urgency=medium
|
||||
|
||||
* pqconly now enforces a PQ-capable peer on member traffic, including on the
|
||||
config-serve path. Previously it enforced nothing and behaved identically
|
||||
to hybrid. See RELEASE-NOTES.md.
|
||||
|
||||
-- Dedy Sutanto <dsutanto@backone.cloud> Thu, 08 Oct 2026 00:00:00 +0700
|
||||
|
||||
backone (2.0.2) unstable; urgency=medium
|
||||
|
||||
* See RELEASE-NOTES.md for release notes.
|
||||
|
||||
@@ -377,14 +377,16 @@ would produce a *different observable*:
|
||||
|---|---|---|---|
|
||||
| HELLO size / fragment count | 137 B / 1 | 137 B / 1 — **unchanged** | no — HELLO carries the classic projection only |
|
||||
| HELLO capability bit | 0 | 1 | yes |
|
||||
| `VERB_PQ_KEYS` frames on wire | none | present, carrying the 1088 B ct | yes |
|
||||
| `VERB_PQ_KEYS` exchange on wire | none | ~13 fragments of one 4257 B packet | yes — but **encrypted**: match on size/fragmentation, not `zt.verb` |
|
||||
| Identity type byte | 0 | 1 | yes |
|
||||
| COM type byte | 1 | 2 | yes |
|
||||
| `_key` value | n/a off-wire | n/a off-wire | **no** — must be inferred from the above |
|
||||
| Session key actually installed | `false` | `true` (`pqcHybridActive`) | yes — the only data-channel assertion |
|
||||
|
||||
Nothing about the negotiated symmetric key is directly observable. A test that
|
||||
only does "ping works" passes trivially under M2 (classical fallback) and must not
|
||||
be counted.
|
||||
The session key is not readable from the wire — data frames are armored, so no
|
||||
filter can reveal it. But its *installation* is directly observable via
|
||||
`pqcHybridActive` (`Peer::hybridSessionKeyInstalled()`), which is a real
|
||||
data-channel assertion. A test that only does "ping works" still passes trivially
|
||||
under M2 (classical fallback) and must not be counted.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
# `pqcMode: pqconly` — manual test and measured result
|
||||
|
||||
Companion to [`two-host-pq-manual-test.md`](./two-host-pq-manual-test.md). That
|
||||
document covers `hybrid`; this one covers `pqconly`, records the defect that
|
||||
motivated it, and documents the enforcement that now backs the name.
|
||||
|
||||
**Status as of 2026-10-08.** `pqconly` used to be a synonym for `hybrid` — it
|
||||
selected a type-1 identity and then enforced nothing, forwarding traffic to a
|
||||
fully classical peer at 0% loss with no warning. That is measured and preserved
|
||||
below in §2. `pqconly` now **enforces** the peer requirement (§3): under
|
||||
`pqconly`, a network will not come up over a link that silently fell back to
|
||||
classical.
|
||||
---
|
||||
|
||||
## 1. What the mode is supposed to mean
|
||||
|
||||
Three values are accepted (`service/OneService.cpp:1436-1443`):
|
||||
|
||||
| `pqcMode` | Identity generated | Intended meaning |
|
||||
|---|---|---|
|
||||
| `off` | type 0, 141 B | classical |
|
||||
| `hybrid` | type 1, 6415 B | use PQ when the peer supports it, else fall back |
|
||||
| `pqconly` | type 1, 6415 B | **PQ required, no classical fallback** |
|
||||
|
||||
Before the fix, `Identity.hpp:4` carried the claim *"pqconly: PQ-only identities,
|
||||
no classic fallback"* — which was false. The comment has since been corrected.
|
||||
|
||||
## 2. The defect: `pqconly` enforced nothing
|
||||
|
||||
*Measured 2026-10-08, before the fix.* `pqconly` selected a type-1 identity and
|
||||
then behaved exactly like `hybrid`. The only runtime site distinguishing the
|
||||
modes was identity generation:
|
||||
|
||||
```c
|
||||
// node/Identity.cpp:105-110
|
||||
if (pqcMode == ZT_PQC_MODE_CLASSIC) { pq = false; }
|
||||
else if (pqcMode == ZT_PQC_MODE_PQCONLY) { pq = true; }
|
||||
```
|
||||
|
||||
After that, every handshake gate tested only `!= CLASSIC`, so the two modes were
|
||||
indistinguishable:
|
||||
|
||||
| Site | Test |
|
||||
|---|---|
|
||||
| `node/Peer.hpp:434` `hybridEligible()` | `pqcMode() != ZT_PQC_MODE_CLASSIC` |
|
||||
| `node/Node.cpp:274` | `pqcMode() != ZT_PQC_MODE_CLASSIC` |
|
||||
| `node/IncomingPacket.cpp:680` | no mode test — only `hybridCapable()` |
|
||||
|
||||
A full-tree grep found no other `ZT_PQC_MODE_PQCONLY` reference in compiled code.
|
||||
Nothing rejected a non-capable peer, and nothing logged anything.
|
||||
|
||||
|
||||
## 3. Reproducing the test
|
||||
|
||||
### 3a. Both hosts on `pqconly`
|
||||
|
||||
```sh
|
||||
# HOST1 (controller)
|
||||
/etc/backone/local.conf -> or /var/lib/backone/local.conf on this lab
|
||||
{
|
||||
"settings": {
|
||||
"pqcMode": "pqconly"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
// HOST2 (member)
|
||||
{
|
||||
"settings": {
|
||||
"pqcMode": "pqconly",
|
||||
"disableController": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```sh
|
||||
sudo systemctl restart backone
|
||||
ssh 192.168.122.85 'sudo systemctl restart backone'
|
||||
```
|
||||
|
||||
Expect — identical to the `hybrid` run in every field:
|
||||
|
||||
```
|
||||
HOST1 6415 bytes dbfa939d58 capable=True hybrid=True
|
||||
HOST2 6415 bytes f4a1ff9427 capable=True hybrid=True
|
||||
```
|
||||
|
||||
`pqcHybridActive: true` on both sides. Identical to the `hybrid` run — both
|
||||
modes agree a PQ peer, and neither is distinguished by that fact.
|
||||
|
||||
### 3b. The decisive test — `pqconly` against a genuinely classical peer
|
||||
|
||||
Setting `pqcMode: off` is **not** enough: the identity is loaded from disk when
|
||||
present, so the type-1 identity survives the change (`node/Node.cpp:96-107`
|
||||
generates only when no identity exists). You must wipe it.
|
||||
|
||||
```sh
|
||||
# HOST2: become a real type-0 peer
|
||||
ssh 192.168.122.85 'sudo systemctl stop backone
|
||||
sudo rm -f /var/lib/backone/identity.secret /var/lib/backone/identity.public
|
||||
sudo systemctl start backone
|
||||
sleep 8
|
||||
cut -d: -f1 /var/lib/backone/identity.public # -> e17bdf70bb
|
||||
stat -c%s /var/lib/backone/identity.public # -> 141 (type 0)'
|
||||
```
|
||||
|
||||
Authorize the new address on HOST1 and join, per §5b/§5c of the main document.
|
||||
|
||||
The table below is what the *current* build does. **The "after enforcement" column
|
||||
is the load-bearing part of this document — it is a design claim that measurement
|
||||
repeatedly contradicted before it was enforced on both sides.** See §4a.
|
||||
|
||||
| | measured, before the fix | required after the fix |
|
||||
|---|---|---|
|
||||
| `paths` to the classical peer | 3 | 3 (handshake still completes) |
|
||||
| `pqcHybridActive` | false | false |
|
||||
| ping HOST1 → HOST2 | **0% loss** | times out, no reply |
|
||||
| network status on HOST2 | OK | never reaches OK |
|
||||
| daemon log on HOST1 | silent | `WARNING: … REFUSED` |
|
||||
| `pkt_network_config_in_pqconly_rejected` | n/a | increments |
|
||||
|
||||
Paths remain because the handshake itself is still allowed — enforcement is
|
||||
scoped to *network membership*, not to peering. Refusing to peer at all would
|
||||
take the node off the root topology, since all four Earth roots are
|
||||
`pqcCapable:false`.
|
||||
|
||||
## 4a. The serve-side hole (why the first fix did not work)
|
||||
|
||||
The first implementation gated only what this node *receives*:
|
||||
|
||||
- `_doNETWORK_CONFIG` — refuse an inbound config from a downgraded peer,
|
||||
- `_doNETWORK_CREDENTIALS` — refuse inbound credentials.
|
||||
|
||||
Measured against `pqconly` HOST1 and a classical HOST2 with the network cache
|
||||
deleted first, the network still came up: `10.97.0.77`, status `OK`, ping
|
||||
**0% loss**. The rejection counter incremented (credentials, in the *other*
|
||||
direction) while traffic flowed anyway.
|
||||
|
||||
The reason is that membership is granted by the *serve* direction. A classic peer
|
||||
sends `VERB_NETWORK_CONFIG_REQUEST` to the node running the controller, and that
|
||||
node — the one actually in `pqconly` — answered from
|
||||
`RR->localNetworkController` with no check at all. The node enforcing the policy
|
||||
never guarded the path that hands out the config. Refusing inbound packets only
|
||||
stops a downgraded peer from pushing a network at us; it does nothing about us
|
||||
handing one to them.
|
||||
|
||||
The fix adds the same gate at `_doNETWORK_CONFIG_REQUEST` before the controller
|
||||
is consulted. Three verbs are now refused, not two:
|
||||
|
||||
| verb | direction | effect |
|
||||
|---|---|---|
|
||||
| `VERB_NETWORK_CONFIG` | in | downgraded peer cannot push a network at us |
|
||||
| `VERB_NETWORK_CREDENTIALS` | in | a COM cannot establish trust over a classical link |
|
||||
| `VERB_NETWORK_CONFIG_REQUEST` | in, gates our **serve** | we do not hand config to a peer we know cannot do PQ |
|
||||
|
||||
## 4b. The rule itself
|
||||
|
||||
|
||||
`Peer::pqconlyPeerRejected()` returns true only when **all** of these hold:
|
||||
|
||||
1. this node's mode is exactly `ZT_PQC_MODE_PQCONLY` — `hybrid` never rejects,
|
||||
2. the peer did **not** advertise the capability bit in its HELLO revision,
|
||||
3. the peer's role is **not** PLANET or MOON.
|
||||
|
||||
Two design points worth knowing before you change it:
|
||||
|
||||
- **The gate keys on `_hybridCapable`, not on `hybridSessionKeyInstalled()`.**
|
||||
Capability is fixed once at HELLO. The hybrid *key* is not: the encapsulating
|
||||
peer derives it before the other side has even seen the ciphertext, and holds it
|
||||
staged until the confirm tag arrives. Gating on the installed key would reject
|
||||
a perfectly good PQ peer for the entire staging window.
|
||||
- **PLANET/MOON are exempt.** All four Earth roots report `pqcCapable:false` and
|
||||
never will; enforcing against them would sever world/world routing.
|
||||
|
||||
Refused: `VERB_NETWORK_CONFIG`, `VERB_NETWORK_CREDENTIALS` and
|
||||
`VERB_NETWORK_CONFIG_REQUEST` (`node/IncomingPacket.cpp`). The first two are
|
||||
receive-side; the third is the serve-side gate that actually stops membership
|
||||
(§4a). Credentials matter most among the receive-side pair — a COM is what
|
||||
establishes trust for a network, so admitting one over a classical link would
|
||||
reinstate the downgrade the mode exists to prevent.
|
||||
|
||||
## 5. The `hybrid` downgrade warning
|
||||
|
||||
`hybrid` still falls back to classical — that is its contract — but no longer
|
||||
silently. When a non-classic-mode node sees a network arriving from a peer that
|
||||
cannot do PQ, `Node::setPQCDowngradeWarning()` logs once per peer:
|
||||
|
||||
```
|
||||
WARNING: peer e17bdf70bb cannot do post-quantum key exchange but this node is in
|
||||
pqcMode hybrid; traffic to it is classical.
|
||||
```
|
||||
|
||||
It warns on *entry* to the downgraded state and again on recovery (an `INFO`
|
||||
line), so a peer that flaps stays visible without one line per packet. `hybrid`
|
||||
keeps forwarding the traffic — the warning is the signal, not a refusal.
|
||||
|
||||
Monitoring notes, if you alert on this: PLANET peers are permanently
|
||||
non-capable, and there is a window before any handshake completes, so exclude
|
||||
`role == "PLANET"` and allow a grace period or you will page on normal operation.
|
||||
|
||||
## 6. Restoring the lab afterwards
|
||||
|
||||
Wiping HOST2's identity destroys it permanently — only `identity.secret` is kept
|
||||
and there is no backup copy. The address changes and must be re-authorized.
|
||||
|
||||
```sh
|
||||
# restore config
|
||||
sudo cp /var/lib/backone/local.conf.bak-hybrid /var/lib/backone/local.conf
|
||||
ssh 192.168.122.85 'sudo cp /tmp/pqconly.conf /var/lib/backone/local.conf'
|
||||
|
||||
# regenerate a type-1 identity and re-enroll
|
||||
ssh 192.168.122.85 'sudo systemctl stop backone
|
||||
sudo rm -f /var/lib/backone/identity.secret /var/lib/backone/identity.public
|
||||
sudo systemctl start backone; sleep 8
|
||||
cut -d: -f1 /var/lib/backone/identity.public' # new address
|
||||
|
||||
# on HOST1, authorize the new address, then join from HOST2
|
||||
curl -s -X POST -H "X-ZT1-Auth: $A" -H 'Content-Type: application/json' \
|
||||
-d '{"authorized":true}' \
|
||||
http://127.0.0.1:9993/controller/network/$NWID/member/<new-addr>
|
||||
|
||||
ssh 192.168.122.85 "/usr/sbin/backone-cli -p9993 -D/var/lib/backone join $NWID"
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```sh
|
||||
curl -s -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/peer | python3 -c "
|
||||
import json,sys
|
||||
for p in json.load(sys.stdin):
|
||||
if p.get('role')!='PLANET': print(p['address'],'hybrid=',p.get('pqcHybridActive'))"
|
||||
```
|
||||
|
||||
Expect `hybrid=True` and 0% loss in both directions.
|
||||
|
||||
## 7. Caveat on the measured addresses
|
||||
|
||||
Addresses in this document are from the 2026-10-08 run. Re-running regenerates
|
||||
identities, so read the current values rather than copying these.
|
||||
@@ -139,10 +139,23 @@ stat -c '%s' /var/lib/backone/identity.public
|
||||
|---|---|---|
|
||||
| absent / `off` | **141 B** | `0` (classic) |
|
||||
| `hybrid` | **6415 B** | `1` (type 1, PQ) |
|
||||
| `pqconly` | 6415 B | `1` |
|
||||
| `pqconly` | 6415 B | `1` — **enforces** PQ on network membership, see below |
|
||||
|
||||
> **`hybrid` vs `pqconly`.** Both write the same PQ material and both reach
|
||||
> `pqcHybridActive: true` against a PQ peer. They differ only in what happens to a
|
||||
> peer that *cannot* do PQ: `hybrid` falls back to classical and logs a one-time
|
||||
> `WARNING`; `pqconly` refuses that peer's network config and credentials, so the
|
||||
> network never comes up over an unprotected link (PLANET/MOON roots are exempt —
|
||||
> they are `pqcCapable:false` and always will be). `pqconly` was previously
|
||||
> indistinguishable from `hybrid` and enforced nothing; see
|
||||
> [`pqconly-mode-test.md`](./pqconly-mode-test.md) for the measurement and the
|
||||
> reproduction steps.
|
||||
|
||||
`identity.public` is a colon-delimited text file (`address:type:flags:...`), so
|
||||
`od` on it reads ASCII, not the type byte. Field 2 is the type:
|
||||
|
||||
```sh
|
||||
od -An -tu1 -N1 /var/lib/backone/identity.public # expect 1 under hybrid
|
||||
cut -d: -f2 /var/lib/backone/identity.public # expect 1 under hybrid
|
||||
/usr/sbin/backone-idtool validate /var/lib/backone/identity.public
|
||||
```
|
||||
|
||||
@@ -295,6 +308,47 @@ for p in json.load(sys.stdin):
|
||||
> The *identity file* is 6415 B because it holds the full type-1 record
|
||||
> (ML-KEM-768 + ML-DSA-65 public keys); the *HELLO packet* is not.
|
||||
|
||||
### 6.3 Data-channel gate — proving the *data* key is PQ-derived
|
||||
|
||||
§6.2 proves the handshake advertises and exchanges PQ material. It does **not**
|
||||
prove the session key protecting your frames came from it. Those are different
|
||||
claims, and the gap matters: `pqcHybridActive` is the closest thing to a direct
|
||||
answer, but read what it actually reports.
|
||||
|
||||
```sh
|
||||
A=$(sudo -n cat /var/lib/backone/authtoken.secret)
|
||||
curl -s -m 8 -H "X-ZT1-Auth: $A" http://127.0.0.1:9993/peer | python3 -c "
|
||||
import json,sys
|
||||
for p in json.load(sys.stdin):
|
||||
if p.get('role') != 'PLANET':
|
||||
print(p['address'], 'capable=', p.get('pqcCapable'), 'hybrid=', p.get('pqcHybridActive'))"
|
||||
```
|
||||
|
||||
| Field | What it actually means |
|
||||
|---|---|
|
||||
| `pqcCapable` | Peer set the capability bit. Advertised support only. |
|
||||
| `pqcHybridActive` | `Peer::hybridSessionKeyInstalled()` — the derived key is **installed into `_key`**, the buffer every data frame is armored with. |
|
||||
|
||||
`pqcHybridActive: true` is a genuine assertion about the data channel, and it is
|
||||
deliberately stricter than "eligible": the code comment at `node/Peer.hpp:710`
|
||||
says eligibility "is true a full round trip before the key exists, so reporting
|
||||
it as 'hybrid active' claims protection that is not in use."
|
||||
|
||||
**Why tcpdump/tshark cannot answer this directly.** Data frames are armored with
|
||||
the session key (`Peer.cpp:645`), so the payload — and the verb byte — is
|
||||
ciphertext. No filter can distinguish a PQ-derived key from a classical one,
|
||||
because that property is not visible in the output of a cipher. Any "the data
|
||||
frames look post-quantum" check is vacuous.
|
||||
|
||||
**The one wire artifact that does bear on it.** `Peer::pqConfirmTag`
|
||||
(`node/Peer.hpp:67`) is `HMAC-SHA384(installed session key, min(addr) ‖
|
||||
max(addr))` truncated to `ZT_PQ_KEYS_CONFIRM_LEN` = 4 bytes, appended **last**
|
||||
in `VERB_PQ_KEYS` so its position is unambiguous. Recomputing it offline under a
|
||||
candidate key and comparing proves which key both peers derived — but it is a
|
||||
verifier requiring the session key, not a passive observation, so it must be
|
||||
run on one of the hosts. Treat it as a lab tool for the key-confirmation path
|
||||
(`IncomingPacket.cpp:1613`), not as a routine capture check.
|
||||
|
||||
---
|
||||
|
||||
## 7. Capture and dissection
|
||||
@@ -322,24 +376,31 @@ tshark -X lua_script:tools/zt-dissector.lua -r /tmp/pq.pcap \
|
||||
| Filter | Shows |
|
||||
|---|---|
|
||||
| `zt` | any BackOne frame |
|
||||
| `zt.verb` | **only on unencrypted frames** — absent on encrypted ones |
|
||||
| `zt.verb == 1` | HELLO only (`Packet.hpp:617`) |
|
||||
| `zt.hello.cap` | capability bit — `0` classical, `1` hybrid |
|
||||
| `zt.hello.idtype` | identity type **in HELLO** — `0` even in hybrid (classic projection only) |
|
||||
| `zt.hello.idsize` | serialized classic identity size (39 B) |
|
||||
| `zt.flags` | cipher suite in bits 3-5; `0x80` is the pre-1.0.3 legacy bit |
|
||||
| `zt.frag` / `zt.fragno` / `zt.fragtot` | fragment header — only for large frames |
|
||||
| `zt.verb == 23` | `VERB_PQ_KEYS` (`0x17`), carries the PQ keys + 1088 B ML-KEM ct |
|
||||
|
||||
**Verified live 2026-10-07** on a hybrid↔hybrid link:
|
||||
|
||||
```
|
||||
ZT HELLO type=0 DBFA939D58 cap=1 # 185 B, single fragment
|
||||
ZT ... Len=1432 # VERB_PQ_KEYS, well over one MTU
|
||||
ZT HELLO type=0 DBFA939D58 cap=1 185 B # unencrypted, cap bit set
|
||||
ZT ... Len=1480 flags=0x58 # PQ_KEYS fragments, cipher 3 (AES-GCM)
|
||||
```
|
||||
|
||||
Expect `cap=1` on HELLO **and** at least one `VERB_PQ_KEYS` frame. The
|
||||
capability bit alone proves only that the peer *advertises* support; the
|
||||
`VERB_PQ_KEYS` frame is what actually carries the material, and a missing one is
|
||||
the signature of bug B7.
|
||||
> **`VERB_PQ_KEYS` is encrypted and its verb is NOT visible.** It is armored
|
||||
> with the *classical* key and `encryptPayload=true` (`Peer.cpp:628`), so byte 27
|
||||
> is ciphertext like any other data packet — that is what lets the peer read it
|
||||
> before it has switched to the hybrid session key. A 4257 B PQ_KEYS arrives as
|
||||
> ~13 fragments at 1480 B each; identify it by **size and fragmentation**, not by
|
||||
> `zt.verb`. The capture above shows 13 such frames.
|
||||
>
|
||||
> The capability bit proves only that the peer *advertises* support. That the
|
||||
> PQ exchange actually happened is a **state** question, answered in §6.3 —
|
||||
> not something a dissector can show.
|
||||
|
||||
**Run tshark as your normal user, not root.** As superuser, Wireshark silently
|
||||
skips user Lua scripts and the dissector appears to be broken. If the pcap lives
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -94,7 +94,7 @@ bool CertificateOfMembership::agreesWith(const CertificateOfMembership &other, c
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CertificateOfMembership::sign(const Identity &with)
|
||||
bool CertificateOfMembership::sign(const Identity &with,bool pqSign)
|
||||
{
|
||||
uint64_t buf[ZT_NETWORK_COM_MAX_QUALIFIERS * 3];
|
||||
unsigned int ptr = 0;
|
||||
@@ -109,7 +109,8 @@ bool CertificateOfMembership::sign(const Identity &with)
|
||||
_signedBy = with.address();
|
||||
// V14: if the signing identity is PQ capable, additionally ML-DSA-65
|
||||
// sign the same bytes so the COM serializes as type 2 (double-sign).
|
||||
if (with.hasPQPrivate()) {
|
||||
// pqSign=false keeps it type 1 for a requester that cannot parse type 2.
|
||||
if ((pqSign) && (with.hasPQPrivate())) {
|
||||
std::shared_ptr<uint8_t> sig(new uint8_t[PQHybrid::MLDSA65_SIG_LEN], std::default_delete<uint8_t[]>());
|
||||
if (! with.pqSign(buf, ptr * sizeof(uint64_t), sig.get())) {
|
||||
_signedBy.zero();
|
||||
|
||||
@@ -195,9 +195,13 @@ public:
|
||||
* Sign this certificate
|
||||
*
|
||||
* @param with Identity to sign with, must include private key
|
||||
* @param pqSign If true and the signing identity has PQ private keys,
|
||||
* additionally ML-DSA-65 sign (COM type 2). Pass false to issue a classic
|
||||
* type-1 COM that a pre-PQ peer can parse: a type 2 COM makes such a peer
|
||||
* throw on the type byte and drop the whole network config.
|
||||
* @return True if signature was successful
|
||||
*/
|
||||
bool sign(const Identity &with);
|
||||
bool sign(const Identity &with,bool pqSign = true);
|
||||
|
||||
/**
|
||||
* Verify this COM and its signature
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// PQC capability mode (local.conf settings.pqcMode / Identity::generate)
|
||||
#define ZT_PQC_MODE_CLASSIC 0 // off: C25519 key agreement only
|
||||
#define ZT_PQC_MODE_HYBRID 1 // hybrid: C25519 agreement with ML-KEM-768 mixed in
|
||||
#define ZT_PQC_MODE_PQCONLY 2 // pqconly: PQ-only identities, no classic fallback
|
||||
#define ZT_PQC_MODE_PQCONLY 2 // pqconly: same PQ material as hybrid, but enforces the peer requirement (see Peer::pqconlyPeerRejected)
|
||||
|
||||
/*
|
||||
* Copyright (c)2019 ZeroTier, Inc.
|
||||
|
||||
@@ -1082,6 +1082,15 @@ bool IncomingPacket::_doNETWORK_CREDENTIALS(const RuntimeEnvironment *RR,void *t
|
||||
return true;
|
||||
}
|
||||
|
||||
// Same pqconly rule as _doNETWORK_CONFIG, and it matters most here: a COM is
|
||||
// what establishes trust for a network, so letting one in over a silently
|
||||
// classical link would reinstate exactly the downgrade the mode forbids.
|
||||
if (peer->pqconlyPeerRejected()) {
|
||||
Metrics::pkt_network_credentials_in_pqconly_rejected++;
|
||||
RR->node->setPQCDowngradeWarning(peer->address(), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
CertificateOfMembership com;
|
||||
Capability cap;
|
||||
Tag tag;
|
||||
@@ -1221,6 +1230,17 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,void
|
||||
const unsigned int hopCount = hops();
|
||||
const uint64_t requestPacketId = packetId();
|
||||
|
||||
// pqconly must also refuse to *serve* config. The receive-side gates in
|
||||
// _doNETWORK_CONFIG / _doNETWORK_CREDENTIALS only protect this node from a
|
||||
// downgraded peer, but a classic peer asks us for its own config and we are
|
||||
// the node in pqconly - gating only inbound let the network come up anyway.
|
||||
if (peer->pqconlyPeerRejected()) {
|
||||
Metrics::pkt_network_config_in_pqconly_rejected++;
|
||||
RR->node->setPQCDowngradeWarning(peer->address(), true);
|
||||
peer->received(tPtr,_path,hopCount,requestPacketId,payloadLength(),Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP,false,nwid,ZT_QOS_NO_FLOW);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RR->localNetworkController) {
|
||||
const unsigned int metaDataLength = (ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_DICT_LEN <= size()) ? at<uint16_t>(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_DICT_LEN) : 0;
|
||||
const char *metaDataBytes = (metaDataLength != 0) ? (const char *)field(ZT_PROTO_VERB_NETWORK_CONFIG_REQUEST_IDX_DICT,metaDataLength) : (const char *)0;
|
||||
@@ -1247,6 +1267,16 @@ bool IncomingPacket::_doNETWORK_CONFIG(const RuntimeEnvironment *RR,void *tPtr,c
|
||||
{
|
||||
Metrics::pkt_network_config_in++;
|
||||
const SharedPtr<Network> network(RR->node->network(at<uint64_t>(ZT_PACKET_IDX_PAYLOAD)));
|
||||
// pqconly refuses a network whose config would arrive over a link that
|
||||
// silently fell back to classical. Infrastructure roles are exempt inside
|
||||
// pqconlyPeerRejected(). This must run before handleConfigChunk(), or the
|
||||
// downgraded config is already applied by the time we notice.
|
||||
if (peer->pqconlyPeerRejected()) {
|
||||
Metrics::pkt_network_config_in_pqconly_rejected++;
|
||||
RR->node->setPQCDowngradeWarning(peer->address(), true);
|
||||
peer->received(tPtr,_path,hops(),packetId(),payloadLength(),Packet::VERB_NETWORK_CONFIG,0,Packet::VERB_NOP,false,at<uint64_t>(ZT_PACKET_IDX_PAYLOAD),ZT_QOS_NO_FLOW);
|
||||
return false;
|
||||
}
|
||||
if (network) {
|
||||
const uint64_t configUpdateId = network->handleConfigChunk(tPtr,packetId(),source(),*this,ZT_PACKET_IDX_PAYLOAD);
|
||||
if (configUpdateId) {
|
||||
|
||||
@@ -54,10 +54,14 @@ namespace ZeroTier {
|
||||
{ packets.Add({{"packet_type", "multicast_like"}, {"direction", "rx"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_network_credentials_in
|
||||
{ packets.Add({{"packet_type", "network_credentials"}, {"direction", "rx"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_network_credentials_in_pqconly_rejected
|
||||
{ packets.Add({{"packet_type", "network_credentials"}, {"direction", "rx"}, {"pqconly_rejected", "yes"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_network_config_request_in
|
||||
{ packets.Add({{"packet_type", "network_config_request"}, {"direction", "rx"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_network_config_in
|
||||
{ packets.Add({{"packet_type", "network_config"}, {"direction", "rx"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_network_config_in_pqconly_rejected
|
||||
{ packets.Add({{"packet_type", "network_config"}, {"direction", "rx"}, {"pqconly_rejected", "yes"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_multicast_gather_in
|
||||
{ packets.Add({{"packet_type", "multicast_gather"}, {"direction", "rx"}}) };
|
||||
prometheus::simpleapi::counter_metric_t pkt_multicast_frame_in
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace ZeroTier {
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_multicast_like_in;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_network_credentials_in;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_network_config_request_in;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_network_credentials_in_pqconly_rejected;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_network_config_in;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_network_config_in_pqconly_rejected;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_multicast_gather_in;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_multicast_frame_in;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_push_direct_paths_in;
|
||||
|
||||
+1
-1
@@ -1311,7 +1311,7 @@ void Network::requestConfiguration(void *tPtr)
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_CAPABILITIES,(uint64_t)ZT_MAX_NETWORK_CAPABILITIES);
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_CAPABILITY_RULES,(uint64_t)ZT_MAX_CAPABILITY_RULES);
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_TAGS,(uint64_t)ZT_MAX_NETWORK_TAGS);
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS,(uint64_t)0);
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS,(uint64_t)((RR->node->pqcMode() != ZT_PQC_MODE_CLASSIC) ? ZT_NETWORKCONFIG_REQUEST_METADATA_FLAG_PQ_CAPABLE : 0));
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_RULES_ENGINE_REV,(uint64_t)ZT_RULES_ENGINE_REVISION);
|
||||
rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_OS_ARCH,ZT_TARGET_NAME);
|
||||
|
||||
|
||||
@@ -132,6 +132,12 @@ namespace ZeroTier {
|
||||
// Network configuration meta-data flags
|
||||
#define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS "f"
|
||||
|
||||
// Set in ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS by requesters that can
|
||||
// parse PQ credential types (COM type 2, identity type 1). Absent means a
|
||||
// classic requester, which cannot parse them, so the controller must issue
|
||||
// classic-format credentials.
|
||||
#define ZT_NETWORKCONFIG_REQUEST_METADATA_FLAG_PQ_CAPABLE 0x0001
|
||||
|
||||
// These dictionary keys are short so they don't take up much room.
|
||||
// By convention we use upper case for binary blobs, but it doesn't really matter.
|
||||
|
||||
|
||||
@@ -624,6 +624,11 @@ ZT_PeerList *Node::peers() const
|
||||
// ever sees the ciphertext, so hybridEligible() reports True a full
|
||||
// round trip early and the decapsulator's failure goes unnoticed.
|
||||
p->pqcHybridActive = pi->second->hybridSessionKeyInstalled();
|
||||
// A peer that has since advertised the capability clears its downgrade
|
||||
// warning, so a later failure warns again instead of staying silent.
|
||||
if (p->pqcCapable) {
|
||||
setPQCDowngradeWarning(pi->second->identity().address(), false);
|
||||
}
|
||||
|
||||
std::vector< SharedPtr<Path> > paths(pi->second->paths(_now));
|
||||
SharedPtr<Path> bestp(pi->second->getAppropriatePath(_now,false));
|
||||
@@ -749,6 +754,64 @@ void Node::setNetconfMaster(void *networkControllerInstance)
|
||||
}
|
||||
}
|
||||
|
||||
// Records a PQC downgrade and warns once per peer per state. Without this a
|
||||
// node configured for hybrid/pqconly silently keeps running on the classical
|
||||
// key against a peer that never offered PQ material, with no log line at all.
|
||||
// Warns on entry to the downgraded state and again on recovery, so a peer that
|
||||
// flaps is visible without log-spamming every packet.
|
||||
void Node::setPQCDowngradeWarning(const Address &addr, bool rejected) const
|
||||
{
|
||||
if (_pqcMode == ZT_PQC_MODE_CLASSIC) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Decide under the lock, print after it is released: fprintf under a lock
|
||||
// would serialize every peer handshake behind the log write.
|
||||
bool shouldWarn = false;
|
||||
{
|
||||
Mutex::Lock _l(_pqcDowngradeWarned_m);
|
||||
|
||||
bool known = false;
|
||||
for(std::vector<Address>::iterator i=_pqcDowngradeWarned.begin();i!=_pqcDowngradeWarned.end();++i) {
|
||||
if (*i == addr) {
|
||||
known = true;
|
||||
if (!rejected) {
|
||||
_pqcDowngradeWarned.erase(i); // recovered, allow a future warning
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rejected) {
|
||||
if (!known) {
|
||||
_pqcDowngradeWarned.push_back(addr);
|
||||
shouldWarn = true;
|
||||
}
|
||||
} else {
|
||||
shouldWarn = known; // only report a recovery if we warned
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldWarn) {
|
||||
return;
|
||||
}
|
||||
|
||||
char addrStr[11];
|
||||
addr.toString(addrStr);
|
||||
if (rejected) {
|
||||
fprintf(stderr,
|
||||
"WARNING: peer %s cannot do post-quantum key exchange but this node is in pqcMode "
|
||||
"%s; traffic to it is classical%s" ZT_EOL_S,
|
||||
addrStr,
|
||||
(_pqcMode == ZT_PQC_MODE_PQCONLY) ? "pqconly" : "hybrid",
|
||||
(_pqcMode == ZT_PQC_MODE_PQCONLY) ? " and network config from it is REFUSED." : ".");
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"INFO: peer %s now reports post-quantum capability; downgrade cleared." ZT_EOL_S,
|
||||
addrStr);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Node methods used only within node/ */
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
void clearLocalInterfaceAddresses();
|
||||
int sendUserMessage(void *tptr,uint64_t dest,uint64_t typeId,const void *data,unsigned int len);
|
||||
void setNetconfMaster(void *networkControllerInstance);
|
||||
void setPQCDowngradeWarning(const Address &addr, bool rejected) const;
|
||||
|
||||
// Internal functions ------------------------------------------------------
|
||||
|
||||
@@ -345,6 +346,8 @@ public:
|
||||
bool _online;
|
||||
bool _lowBandwidthMode;
|
||||
int _pqcMode;
|
||||
mutable std::vector<Address> _pqcDowngradeWarned;
|
||||
mutable Mutex _pqcDowngradeWarned_m;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "RingBuffer.hpp"
|
||||
#include "SelfAwareness.hpp"
|
||||
#include "Switch.hpp"
|
||||
#include "Topology.hpp"
|
||||
#include "Trace.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
@@ -169,6 +170,18 @@ void Peer::ensurePendingHybridCt()
|
||||
Utils::burn(hkey, sizeof(hkey));
|
||||
}
|
||||
|
||||
bool Peer::pqconlyPeerRejected() const
|
||||
{
|
||||
if (RR->node->pqcMode() != ZT_PQC_MODE_PQCONLY) {
|
||||
return false;
|
||||
}
|
||||
if (_hybridCapable) {
|
||||
return false;
|
||||
}
|
||||
const ZT_PeerRole r = RR->topology->role(address());
|
||||
return ((r != ZT_PEER_ROLE_PLANET) && (r != ZT_PEER_ROLE_MOON));
|
||||
}
|
||||
|
||||
void Peer::received(
|
||||
void *tPtr,
|
||||
const SharedPtr<Path> &path,
|
||||
|
||||
@@ -433,6 +433,24 @@ public:
|
||||
inline bool hybridEligible() const
|
||||
{ return ((RR->node->pqcMode() != ZT_PQC_MODE_CLASSIC) && (_hybridCapable) && (RR->identity.hasPQ()) && _pqKeysValid); }
|
||||
|
||||
/**
|
||||
* True when this node enforces pqconly and the peer is a non-infrastructure
|
||||
* peer that cannot do PQ, i.e. traffic to it would be silently classical.
|
||||
*
|
||||
* The gate keys on _hybridCapable -- set once at HELLO and stable -- and not
|
||||
* on hybridSessionKeyInstalled(). A capable peer stages its hybrid key until
|
||||
* the confirm tag arrives, so testing the installed key would reject a
|
||||
* perfectly good PQ peer for the whole staging window.
|
||||
*
|
||||
* Roots are exempt: planets and moons are infrastructure this node dials for
|
||||
* world/world routing, they are not network members, and no classical planet
|
||||
* build will ever advertise the capability bit. Enforcing against them would
|
||||
* cut the node off from the root topology.
|
||||
*
|
||||
* Defined in Peer.cpp: Topology is only forward-declared here.
|
||||
*/
|
||||
bool pqconlyPeerRejected() const;
|
||||
|
||||
/**
|
||||
* Rate limit gate for VERB_PUSH_DIRECT_PATHS
|
||||
*/
|
||||
|
||||
@@ -808,6 +808,31 @@ static int testCertificate()
|
||||
}
|
||||
}
|
||||
std::cout << "PASS" << std::endl;
|
||||
|
||||
// A controller must be able to issue a classic type-1 COM even when its
|
||||
// signing identity holds PQ keys: a pre-PQ requester parses only type 1
|
||||
// and throws on type 2, silently dropping the whole network config.
|
||||
std::cout << "[certificate] PQ authority can issue classic COM on demand... ";
|
||||
CertificateOfMembership c1pq(10000, 100, 1, idA);
|
||||
if ((! c1pq.sign(pqAuthority, false)) || (c1pq.pqSignature() != (const uint8_t*)0)) {
|
||||
std::cout << "FAIL (sign)" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
b.clear();
|
||||
c1pq.serialize(b);
|
||||
if (b[0] != 1) {
|
||||
std::cout << "FAIL (type byte)" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
CertificateOfMembership c1pqb;
|
||||
c1pqb.deserialize(b, 0);
|
||||
if (c1pqb != c1pq) {
|
||||
std::cout << "FAIL (round trip)" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
std::cout << "PASS" << std::endl;
|
||||
}
|
||||
|
||||
// A controller holds the member's full identity (type 1) but only ever sees
|
||||
|
||||
+1
-1
@@ -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) */
|
||||
|
||||
Executable
+183
@@ -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
|
||||
+16
-4
@@ -10,6 +10,10 @@ local IDENTITY_SIZE_CLASSIC = 39 -- 5 addr + 1 type + 32 pub + 1 privlen
|
||||
local IDENTITY_SIZE_PQ = 3175 -- classic + 1184 ML-KEM-768 pk + 1952 ML-DSA-65 pk
|
||||
local HELLO_IDENTITY_OFF = 13 -- payload + (pv1+maj1+min1+rev2+timestamp8)
|
||||
|
||||
local CIPHER_NONE = 0 -- C25519_POLY1305_NONE, payload left in the clear
|
||||
local CIPHER_SALSA20 = 1 -- C25519_POLY1305_SALSA2012
|
||||
local CIPHER_AES_GCM = 3 -- AES_GMAC_SIV
|
||||
|
||||
local f = {
|
||||
iv = ProtoField.bytes("zt.iv", "Packet ID / IV"),
|
||||
dest = ProtoField.string("zt.dest", "Destination"),
|
||||
@@ -83,14 +87,22 @@ function zt.dissector(buf, pinfo, tree)
|
||||
|
||||
if buf:len() < 28 then return end
|
||||
|
||||
local verb = buf(27, 1):uint()
|
||||
local encrypted = bit.band(buf(18, 1):uint(), 0x80) ~= 0
|
||||
local t = tree:add(zt, buf(), "BackOne, verb " .. verb)
|
||||
-- Cipher suite lives in flags bits 3-5 (FFCCCHHH, Packet.hpp:1319). Suite 0
|
||||
-- (C25519_POLY1305_NONE) leaves the payload in the clear; suites 1 and 3
|
||||
-- encrypt from ZT_PACKET_IDX_VERB (27) onward, so byte 27 is ciphertext and
|
||||
-- must not be presented as a verb. Checking only the pre-1.0.3 0x80 bit
|
||||
-- misreads every AES-GCM frame, which is what a PQ link uses.
|
||||
local cipher = bit.band(bit.rshift(buf(18, 1):uint(), 3), 0x07)
|
||||
local encrypted = (cipher ~= CIPHER_NONE) and (cipher == CIPHER_SALSA20 or cipher == CIPHER_AES_GCM)
|
||||
local verb = encrypted and 0 or buf(27, 1):uint()
|
||||
local t = tree:add(zt, buf(), encrypted and "BackOne, encrypted" or ("BackOne, verb " .. verb))
|
||||
t:add(f.iv, buf(0, 8))
|
||||
t:add(f.dest, addr(buf, 8))
|
||||
t:add(f.src, addr(buf, 13))
|
||||
t:add(f.flags, buf(18, 1))
|
||||
t:add(f.verb, buf(27, 1))
|
||||
if not encrypted then
|
||||
t:add(f.verb, buf(27, 1))
|
||||
end
|
||||
|
||||
-- Head of a fragmented packet still carries the original header, so the
|
||||
-- verb and the leading payload bytes are parseable.
|
||||
|
||||
Reference in new issue
Block a user