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:
proitlab committed 2026-10-08 10:33:12 +00:00
1 parent 975148525b
commit 2e2b0910a8
11 files changed
+258 -55

No files matched your search

+109 -44
View File
@@ -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.
+9 -7
View File
@@ -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