mirror of
https://github.com/jmcorgan/fips.git
synced 2026-10-05 19:18:25 +00:00
Carries the security batch onto this line. Most of it merged as text; the forged-ack rollback had to be re-implemented, because this line runs XX where the other two run XK and the function the helper wraps does not exist here. The defect is the same shape under XX: the reader mixes the sender ephemeral into the symmetric state before the first authenticating operation, so a forged message poisons a handshake that is then kept. The saved field set is larger here, five rather than four, and the extra one matters: XX msg2 carries the responder static and stores it before the epoch decrypt that can still fail, so a failed read would otherwise leave an attacker key where the identity check reads it. The helper returns a rollback token rather than unit, because the two extra failure sites on this line need to roll back after a read that succeeded. Both of those sites now keep the entry. The negotiation-payload failure is plainly forgery-reachable, since the identity comparison has not run yet. The responder-identity mismatch is the sharper case and also keeps: it proves the sender of the datagram is not who we dialled, but the claimed source is an envelope field, so the forgery reading is available to anyone who can reach us, and dropping would hand out a one-datagram cancel of any initiation. It was a silent return and now has its own counter, kept separate from the read failure so a stale key mapping and somebody answering under their own identity cannot be summed together. This line carries six sites of the epoch-discard class, not the five the other lines have; the sixth is the negotiation payload split out of XX msg3. One fix was dropped by a clean auto-merge and restored: the change at the msg3 read failure slid onto an adjacent site that is unique to this line, leaving the original with the destructive call, no conflict and no warning. Its doc comment, counters and tests all arrived without it. Caught by sweeping the cleanly-merged files, and confirmed by reverting the line and watching the epoch-survival assertion fail. The profiler row-count guard is updated for the step this merge brings up. It has now caught a merged-in step twice. Green: fmt, build, clippy and test --lib, 1956 passed, plus the profiling recorder suite.
NAT Lab Harness
Real Docker-based NAT traversal integration tests for the mainline FIPS Nostr/STUN bootstrap path.
This harness spins up:
- two FIPS nodes
- a local Nostr relay
- a local STUN server
- one or two Linux router containers performing NAT with
iptables
For the NAT scenarios, the node LAN interfaces are not attached to
Docker bridge networks. The harness creates explicit veth pairs and
moves them into the node and router namespaces after docker compose up
so every packet must traverse the router namespace.
It covers three scenarios:
cone: both peers behind explicit namespace/veth full-cone emulation, UDP traversal succeedssymmetric: both peers behind symmetric-style NAT, UDP traversal fails, TCP fallback succeedslan: both peers share a LAN subnet, LAN targets are preferred over reflexive addresses
NAT model notes
The harness does not rely on plain Docker MASQUERADE for the cone case.
cone- uses explicit full-cone emulation in the router namespace
- outbound UDP is
SNATed to the router WAN address while preserving the source port - inbound UDP to the router WAN address is
DNATed back to the single LAN host regardless of remote source
symmetric- uses UDP
MASQUERADE --random-fully - outbound mappings may be port-randomized and are only reopened by matching conntrack state
- uses UDP
This distinction matters because plain MASQUERADE is convenient source NAT, but it does not by itself model the "accept from any remote once mapped" behavior expected from a full-cone NAT.
Prerequisites
- Docker with Compose support
- locally built
fips-test:latest
Build the test image with:
./testing/scripts/build.sh
Run
Run all scenarios:
./testing/nat/scripts/nat-test.sh
Run one scenario:
./testing/nat/scripts/nat-test.sh cone
./testing/nat/scripts/nat-test.sh symmetric
./testing/nat/scripts/nat-test.sh lan
Layout
docker-compose.yml- relay/STUN/WAN topology plus container definitions
node/- node bootstrap wrapper that waits for the injected veth interface
router/- NAT router image and
iptablessetup
- NAT router image and
stun/- minimal STUN binding responder
relay/- local
strfryconfig
- local
scripts/generate-configs.sh- derives ephemeral identities and writes per-scenario FIPS configs
scripts/setup-topology.sh- injects and configures the NAT LAN
vethpairs in the container namespaces
- injects and configures the NAT LAN
scripts/nat-test.sh- boots the lab, waits for convergence, and asserts the resulting path
Assertions
-
cone- both nodes connect
- connected transport is UDP
- active link remote addresses are on the WAN NAT subnet
-
symmetric- NAT bootstrap does not establish a UDP link
- fallback converges
- connected transport is TCP via router-published WAN addresses
-
lan- both nodes connect
- connected transport is UDP
- active link remote addresses stay on the shared LAN subnet