Files
BackOne/docs/pqconly-mode-test.md
T
proitlab 2e2b0910a8
build.yml / build_ubuntu (push) Canceled after 0s
build.yml / build_macos (push) Canceled after 0s
build.yml / build_windows (push) Canceled after 0s
Lint / clang-format (push) Canceled after 0s
validate.yml / build_ubuntu (push) Canceled after 0s
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.
2026-10-08 10:33:12 +00:00

9.3 KiB

pqcMode: pqconly — manual test and measured result

Companion to 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.

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:

// 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

# HOST1 (controller)
/etc/backone/local.conf  ->  or /var/lib/backone/local.conf on this lab
{
  "settings": {
    "pqcMode": "pqconly"
  }
}
// HOST2 (member)
{
  "settings": {
    "pqcMode": "pqconly",
    "disableController": true
  }
}
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.

# 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.

# 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:

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.