fix(controller): issue classic COM to pre-PQ requesters

A hybrid controller always double-signed the COM, so it serialized with type
byte 2. A legacy (v1.14.1) client's COM parser rejects any type != 1, which
threw inside NetworkConfig::fromDictionary; handleConfigChunk swallowed it, so
the client sat at REQUESTING_CONFIGURATION forever and surfaced as
ACCESS_DENIED once the network was private and its member unapproved.

Advertise PQ capability in the network-config-request metadata ("f" bit 0,
previously hardcoded 0) and let the controller pick the wire form per
requester: type 2 only for a requester that flagged the bit, type 1 otherwise
(all legacy clients, and push configs with no request metadata).

Verified: selftest's new "PQ authority can issue classic COM on demand" case
passes, and a real v1.14.1 client reaches status OK / netconfRevision 5
against a pqcMode:hybrid controller while a hybrid client still comes up OK.
This commit is contained in:
proitlab committed 2026-12-04 18:00:43 +07:00
1 parent e5e2990a68
commit 6c23665072
7 files changed
+48 -5

No files matched your search

+2
View File
@@ -77,6 +77,7 @@ Derived from `selftest.cpp` + CI gates. `?` = code-derived, no test yet.
| 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)
@@ -129,3 +130,4 @@ Not tracked (low value `?`): `one.cpp:256` port/token cleanup, `MacKextEthernetT
| 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` |
+6 -1
View File
@@ -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);
+3 -2
View File
@@ -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();
+5 -1
View File
@@ -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
View File
@@ -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);
+6
View File
@@ -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.
+25
View File
@@ -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