pqconly: enforce PQ peers, including on the config-serve path
`pqconly` selected a type-1 identity and then behaved exactly like `hybrid` at runtime: every handshake gate tested only `pqcMode() != CLASSIC`, so nothing distinguished the two modes and no non-capable peer was ever refused. Measured on the two-host lab, a `pqconly` node carried traffic with a fully classical peer at 0% loss. Add `Peer::pqconlyPeerRejected()` - true when this node is exactly `pqconly`, the peer did not advertise the HELLO capability bit, and its role is not PLANET/MOON (all four Earth roots are `pqcCapable:false` and enforcing against them would cut the node off the root topology). Three verbs are gated, and the third is load-bearing. The first implementation gated only `VERB_NETWORK_CONFIG` and `VERB_NETWORK_CREDENTIALS` and still let the classical peer join at 0% loss, 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. Gating `VERB_NETWORK_CONFIG_REQUEST` before the controller is consulted closes it. The rejection counter had been incrementing in the unrelated direction throughout, which is what made the false assurance possible. `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. 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 entire staging window. Measured 2026-10-08, two-host lab, clean rebuild, selftest exit 0: - `pqconly` vs classical: network now sits at REQUESTING_CONFIGURATION with assignedAddresses [] and 100% loss, down from OK at 0% loss. - `pqconly` vs `pqconly`: 0% loss both directions, no false rejection.
This commit is contained in:
1 parent
975148525b
commit
2e2b0910a8
11 files changed
+258
-55
No files matched your search
@@ -16,7 +16,8 @@ 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)
|
||||
- OUT: AES-256-GCM swap, trusted-path skipCrypto, forward secrecy, protocol standardization, crypto audit, production release/signing
|
||||
@@ -37,7 +38,7 @@ 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.rules | rules compiler | `node rule-compiler/cli.js <rules>` → rules/tags JSON |
|
||||
@@ -67,6 +68,7 @@ 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` |
|
||||
|
||||
## §T (tasks)
|
||||
|
||||
@@ -96,7 +98,7 @@ 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 |
|
||||
|
||||
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`.
|
||||
@@ -113,3 +115,4 @@ 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`. |
|
||||
+109
-44
@@ -1,14 +1,15 @@
|
||||
# `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 the third mode and records what it
|
||||
actually does, which is not what its name implies.
|
||||
|
||||
**Headline result (measured 2026-10-08, two real hosts):** `pqconly` behaves
|
||||
**identically to `hybrid` at runtime**. It does not fail closed, it does not
|
||||
refuse classical peers, and it carries traffic with a peer that has no PQ
|
||||
capability. Treat it as a synonym for `hybrid`, not as a stricter policy mode.
|
||||
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
|
||||
@@ -21,12 +22,14 @@ Three values are accepted (`service/OneService.cpp:1436-1443`):
|
||||
| `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** |
|
||||
|
||||
The `Identity.hpp:4` comment states the intent plainly: *"pqconly: PQ-only
|
||||
identities, no classic 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. What it actually does
|
||||
## 2. The defect: `pqconly` enforced nothing
|
||||
|
||||
Only one runtime site distinguishes the modes — identity generation:
|
||||
*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
|
||||
@@ -34,8 +37,8 @@ if (pqcMode == ZT_PQC_MODE_CLASSIC) { pq = false; }
|
||||
else if (pqcMode == ZT_PQC_MODE_PQCONLY) { pq = true; }
|
||||
```
|
||||
|
||||
After that, every handshake gate tests only `!= CLASSIC`, so `hybrid` and
|
||||
`pqconly` are indistinguishable:
|
||||
After that, every handshake gate tested only `!= CLASSIC`, so the two modes were
|
||||
indistinguishable:
|
||||
|
||||
| Site | Test |
|
||||
|---|---|
|
||||
@@ -43,8 +46,9 @@ After that, every handshake gate tests only `!= CLASSIC`, so `hybrid` and
|
||||
| `node/Node.cpp:274` | `pqcMode() != ZT_PQC_MODE_CLASSIC` |
|
||||
| `node/IncomingPacket.cpp:680` | no mode test — only `hybridCapable()` |
|
||||
|
||||
A full-tree grep finds no other `ZT_PQC_MODE_PQCONLY` reference in compiled code.
|
||||
Nothing rejects a non-capable peer when `pqconly` is set.
|
||||
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
|
||||
|
||||
@@ -82,7 +86,8 @@ HOST1 6415 bytes dbfa939d58 capable=True hybrid=True
|
||||
HOST2 6415 bytes f4a1ff9427 capable=True hybrid=True
|
||||
```
|
||||
|
||||
`pqcHybridActive: true`. Identical results confirm the modes share a code path.
|
||||
`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
|
||||
|
||||
@@ -102,39 +107,99 @@ 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.
|
||||
|
||||
Then, with HOST1 on `pqconly` and HOST2 now classical:
|
||||
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:
|
||||
|
||||
```
|
||||
# HOST1's view of the classical peer
|
||||
e17bdf70bb capable=False hybrid=False paths=3
|
||||
|
||||
# HOST1 -> HOST2 overlay IP
|
||||
4 packets transmitted, 4 received, 0% packet loss
|
||||
WARNING: peer e17bdf70bb cannot do post-quantum key exchange but this node is in
|
||||
pqcMode hybrid; traffic to it is classical.
|
||||
```
|
||||
|
||||
**`pqconly` exchanged packets with a peer that has no PQ keys at all.** If the
|
||||
mode meant what it says, `paths` would be 0 and the ping would fail.
|
||||
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.
|
||||
|
||||
## 4. Interpretation
|
||||
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.
|
||||
|
||||
A `pqconly` node is not protected against downgrade. An attacker who can keep a
|
||||
peer from ever exchanging PQ material leaves the link on the classical session
|
||||
key, and `pqcHybridActive` will simply report `false` — quietly, with no log line
|
||||
and no refusal to forward traffic.
|
||||
|
||||
Two consequences:
|
||||
|
||||
1. **`pqconly` must not be relied on as a policy control.** It selects an
|
||||
identity type. It does not enforce a peer requirement.
|
||||
2. **Monitoring `pqcHybridActive` is the only available detection.** A peer that
|
||||
should be hybrid but reports `hybrid=False` is a downgrade, and nothing else
|
||||
in the node will tell you.
|
||||
|
||||
Making the mode real would mean gating `hybridEligible()` — or a sibling check —
|
||||
on `== ZT_PQC_MODE_PQCONLY`, and dropping peers that fail it. That is a behavior
|
||||
change and is **not** implemented today.
|
||||
|
||||
## 5. Restoring the lab afterwards
|
||||
## 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.
|
||||
@@ -169,7 +234,7 @@ for p in json.load(sys.stdin):
|
||||
|
||||
Expect `hybrid=True` and 0% loss in both directions.
|
||||
|
||||
## 6. Caveat on the measured addresses
|
||||
## 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,14 +139,16 @@ 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` — **behaves identically to `hybrid`, see below** |
|
||||
| `pqconly` | 6415 B | `1` — **enforces** PQ on network membership, see below |
|
||||
|
||||
> **`pqconly` is not a stricter mode.** Despite the "no classic fallback" comment
|
||||
> in `node/Identity.hpp:4`, it only forces a type-1 identity at generation
|
||||
> (`node/Identity.cpp:109`); every runtime gate tests `pqcMode() != CLASSIC`, so
|
||||
> it shares a code path with `hybrid`. Measured: a `pqconly` node carried traffic
|
||||
> with a fully classical peer, 0% loss. See
|
||||
> [`pqconly-mode-test.md`](./pqconly-mode-test.md) for the full result and the
|
||||
> **`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
|
||||
|
||||
+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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user