Skip to content

M4 — UDP protocol payloads (core::payload), the port of payload.cc - #56

Merged
kj299 merged 1 commit into
masterfrom
claude/m4-udp-payloads
Jul 25, 2026
Merged

kj299 merged 1 commit into
masterfrom
claude/m4-udp-payloads

Conversation

@kj299

@kj299 kj299 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Backlog #2: a bare UDP probe only elicits a reply from a service that answers anything, so most open UDP ports read open|filtered. nmap sends a protocol-specific payload on well-known ports — a DNS query to 53, an SNMP get to 161 — which coaxes a real answer. This ports that.

The finding that shaped the design

nmap has no payload data file. Modern payload.cc derives the table from nmap-service-probes: every Probe UDP line not flagged no-payload contributes its probe string as a payload for each port in its ports directive (probablePorts — not sslports).

core::probedb already parses all of that, including the no-payload flag, from M3. So core::payload is a pure index over data we already parse and fuzz — no new file format, no new untrusted-input parser, no new fuzz target.

What lands

core::payload — from_probe_db mirrors init_payloads(); count/for_port/get reproduce udp_payload_count and udp_port2payload (including its index wrap); probe_payloads gives the datagrams for one logical probe, the C's MAX(numpayloads, 1) loop.

sys::group — RawScanKind::build_probe becomes build_probes -> Vec<Vec<u8>>: a UDP probe sends one datagram per registered payload, all from the same encoded source port. SYN and flag kinds return a single packet. Because the datagrams share a source port, a reply cannot be attributed to a particular payload (the C notes this too), so the engine keeps one outstanding entry per (port, tryno) and matches by port. A payload that cannot be built is skipped rather than suppressing its siblings.

core::udpscan — build_udp_probe_with takes an explicit payload; build_udp_probe keeps the bare datagram.

cli — loads the table through the existing nmap-service-probes loader, degrading to bare datagrams with a notice when absent.

Verification

Differential. payload_corpus.rs runs over the real 2.5 MB file and agrees with an independent derivation on all 33 205 (port, payload) pairs across 33 110 ports, max 4 per port — plus per-port counts for 53/111/123/137/161/500/1900/5353 and byte-level anchors (DNS 12-byte header, ASN.1 SEQUENCE on SNMP, SSDP M-SEARCH on 1900).

On the wire. The on-the-wire differential now covers payload-carrying datagrams, including an odd-length payload (the checksum's trailing-byte padding path).

Live proof it works. A responder that answers only well-formed (≥12 byte) queries, on port 53 (payloads registered) and 5399 (none):

53/udp   open            domain
5399/udp open|filtered   securitychase

responder log:
  port 53:   answered a 30-byte query    <- all three registered DNS payloads
  port 53:   answered a 12-byte query
  port 53:   answered a 46-byte query
  port 5399: ignored a 0-byte datagram   <- bare probe, no payload registered

The payload is the entire difference between open and open|filtered.

Gates

fmt + clippy (default and all-features) on pinned 1.97.0 · 318 core tests · miri clean · unsafe-audit 11/11 documented, 0 undocumented (no new unsafe) · cargo deny clean · fuzz services_probes_parse extended to cover the derivation (356k runs, no crashes — same input domain, existing corpus, so no new CI target).

Ledger

udpscan-empty-payload resolved. New:

  • payload-cap-warns-not-fatal — the C fatal()s if a port exceeds MAX_PAYLOADS_PER_PORT (a limit that exists only because its count/index are u8); we keep the ceiling so the payload sequence matches but truncate and report instead of killing the scan.
  • payload-missing-db-degrades — C nmap fatal()s when it cannot load nmap-service-probes, failing a -sU scan outright on a stripped install; we warn and scan with bare datagrams.
  • payload-one-datagram-per-payload — documents that the group congestion window counts logical probes, not datagrams, so -sU pacing is slightly more permissive than the C's per-datagram accounting.

Remaining in backlog #2

SYN/flag ICMP back-fill — core::udpscan::embedded_probe already returns the quoted destination, which is what attributes an error to the right host in a group scan.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w


Generated by Claude Code

Backlog #2: a bare UDP probe only elicits a reply from a service that
answers anything, so most open UDP ports read open|filtered. nmap sends a
protocol-specific payload on well-known ports; this ports that.

The finding that shaped the design: nmap has no payload data file. Modern
payload.cc DERIVES the table from nmap-service-probes — every `Probe UDP`
line not flagged `no-payload` contributes its probe string to each port in
its `ports` directive (probablePorts, not sslports). core::probedb already
parses all of that, including the no-payload flag, so core::payload is a
pure index over data we already parse and fuzz: no new file format, no new
untrusted-input parser.

core::payload
  - from_probe_db mirrors init_payloads(); count/for_port/get reproduce
    udp_payload_count and udp_port2payload (including its index wrap).
  - probe_payloads gives the datagrams for one logical probe — the C's
    MAX(numpayloads, 1) loop.

sys::group
  - RawScanKind::build_probe becomes build_probes -> Vec<Vec<u8>>: a UDP
    probe sends one datagram per registered payload, all from the same
    encoded source port. SYN and flag kinds return a single packet.
  - Because the datagrams share a source port, a reply cannot be tied to a
    particular payload (the C says so too), so the engine keeps one
    outstanding entry per (port, tryno) and matches by port.
  - A payload that cannot be built is skipped rather than suppressing its
    siblings; the probe fails only if nothing could be built.

core::udpscan: build_udp_probe_with takes an explicit payload;
build_udp_probe keeps the bare datagram.

cli: loads the table via the existing nmap-service-probes loader and
degrades to bare datagrams with a notice when it is absent. C nmap fatal()s
there, failing the whole scan over an optional data file.

Verification
  - payload_corpus.rs: over the real 2.5 MB file our table agrees with an
    independent derivation on all 33205 (port, payload) pairs across 33110
    ports, max 4 per port, plus per-port counts and byte-level anchors for
    53/111/123/137/161/500/1900/5353 (DNS header, ASN.1 SEQUENCE on SNMP,
    SSDP M-SEARCH).
  - Unit tests that both payloads for a port reach the wire, and that the
    bare kind attaches nothing.
  - On-the-wire differential extended to payload-carrying datagrams,
    including an odd-length payload (checksum padding path).
  - Live: a responder answering only well-formed queries reads `open` on
    port 53 (all three DNS payloads delivered) and `open|filtered` on 5399
    where no payload is registered — the payload is the whole difference.

Gates: fmt + clippy (default and all-features) on 1.97.0; 318 core tests;
miri clean; unsafe-audit 11/11 documented, 0 undocumented; cargo deny clean;
fuzz services_probes_parse extended to cover the derivation, 356k runs no
crashes; all four privileged e2e suites pass as root.

Ledger: udpscan-empty-payload resolved; new payload-cap-warns-not-fatal
(truncate + report instead of the C's fatal), payload-missing-db-degrades,
payload-one-datagram-per-payload.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
@kj299
kj299 marked this pull request as ready for review July 25, 2026 13:24
@kj299
kj299 merged commit f9d52be into master Jul 25, 2026
12 checks passed
kj299 pushed a commit that referenced this pull request Nov 14, 2026
Three of the six are older lessons that did not fire (#42 CI liveness,
#41 review every step, #47 defaults are inputs); each now has a command
that fails. The others:
- #56: Phase 0 read nmap's --send-eth path as its default, and the
  claim stood four steps because the oracle could not run here. The
  threat model gains a register of claims read but not measured, each
  traced from the option's default, and a table of the checks each
  received message's standard requires of a receiver. The flaw scanner
  found 0 of the milestone's 3 C defects: each is an absent check.
- #57: a flag a gate script passes on every run is a matrix column with
  one value (-Pn hid a two-milestone-old defect).
PLAYBOOK (400 lines), REVIEW-GATE, ORACLE-CHECKS, the prompts and all six
skills carry them; check-kit passes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants