Skip to content

M4 module 14 — core::ipid: IP-ID sequence classification - #45

Merged
kj299 merged 1 commit into
masterfrom
claude/m4-core-ipid
Jul 20, 2026
Merged

kj299 merged 1 commit into
masterfrom
claude/m4-core-ipid

Conversation

@kj299

@kj299 kj299 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Fourteenth Milestone-4 core module. Ports nmap's get_ipid_sequence_16 / get_ipid_sequence_32 / get_diffs / identify_sequence (osscan2.cc): classify how a host generates its IP identification field from a run of observed IP-IDs.

What & why

Classes: Constant / Zero / Incr / IncrBy2 / BrokenIncr (byte-swapped) / Rpi (random-positive-increment) / Rd (random) / Unknown. Feeds two consumers — the idle scan (-sI, which needs a predictable incremental zombie) and OS detection (the TI/CI/II/SS fingerprint tests). A pure function over the samples: no I/O, no globals.

Fidelity note (documented in the module, not a divergence)

The C's 16-bit path computes diffs as full 32-bit wrapping subtractions and flags a diff > 20000 as random before masking to 16 bits — so a single 16-bit counter wrap mid-run classifies as Rd. That is heuristic imprecision, not a memory-safety issue, so the port reproduces it exactly. "Fixing" it would silently change OS-detection output and break bit-exact parity with nmap.

Gates

Gate Result
ported ✅ core::ipid, forbid(unsafe), total (wrapping/checked arithmetic; no unsigned underflow in the localhost RST-IPID adjustment)
differential ✅ 64/64 crafted cases (every class × 16/32-bit × localhost/not, plus 16-bit wrap, near-threshold jumps, u32 extremes) vs a near-verbatim C transcription (ipid_oracle), reinforced by a 12000-sequence randomized C-vs-Rust cross-check: 0 mismatches
fuzzed ✅ fuzz/ipid — 11.2M runs, 0 crashes
sanitized ✅ miri 11/11, no UB
unsafe-audited ✅ 0 unsafe in workspace
tests ✅ 11 unit tests (all classes, localhost adjustment, 16-bit-wrap-as-Rd quirk, totality sweep)

The corpus is reproducible (gen_ipid_cases.py → ipid_cases.txt; ipid_oracle → golden).

C tree untouched. 14 M4 core modules now done — the full core packet/scan logic (primitives, 7 header parsers, packet_parser, build, recv_validate, classify, ipid) is in place. Next comes the sys layer (netif enumeration, Npcap FFI, raw send/capture — the unsafe-bearing OS-acquisition modules) and the scan drivers.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w


Generated by Claude Code

Fourteenth Milestone-4 core module. Ports nmap's get_ipid_sequence_16 /
get_ipid_sequence_32 / get_diffs / identify_sequence (osscan2.cc): classify how
a host generates its IP identification field (constant / zero / incremental /
incremental-by-2 / byte-swapped "broken" incremental / random-positive-increment
/ random) from a run of observed IP-IDs. Feeds the idle scan (-sI zombie
selection) and OS detection (TI/CI/II/SS fingerprint tests). A pure function over
the samples.

Fidelity note (documented in the module, not a divergence): the C 16-bit path
computes diffs as full 32-bit wrapping subtractions and flags a diff > 20000 as
random BEFORE masking to 16 bits, so a single 16-bit wrap mid-run classifies as
Rd. This is heuristic imprecision, not a memory-safety issue, so the port
reproduces it exactly — "fixing" it would silently change OS-detection output and
break bit-exact parity.

Gates:
- ported: core::ipid, forbid(unsafe), total (wrapping/checked arithmetic
  throughout; no unsigned underflow in the localhost RST-IPID adjustment)
- differential: 64/64 crafted cases (every class x 16/32-bit x localhost) vs a
  near-verbatim C transcription (ipid_oracle), reinforced by a 12000-sequence
  randomized C-vs-Rust cross-check: 0 mismatches.
- fuzzed: fuzz/ipid — 11.2M runs, 0 crashes
- sanitized: miri 11/11, no UB
- unsafe-audited: 0 unsafe in workspace

C tree untouched. 14 M4 core modules now done.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
@kj299
kj299 marked this pull request as ready for review July 20, 2026 16:30
@kj299
kj299 merged commit 6278a0e into master Jul 20, 2026
12 checks passed
kj299 pushed a commit that referenced this pull request Oct 13, 2026
…veness

Patches the kit with what nmap's M6.6 (nmapdb, LPeg, the Lua base
library) taught. Each change names the failure it prevents next time:

- LESSONS #40-#51, under a new "M6.6" header, with a meta note.
- #40 Resource bounds (PLAYBOOK step 4b, RESOURCE-BOUNDS.md, new
  harnesses/scaling/scale_check.py in check-kit): every gate was green
  while json.parse of a network body ran 1,600x C's time and strings were
  retained at 525 MB against 4 MB. Pre-emptible is not bounded.
- #41 Review gate (gate 6 rewritten, REVIEW-GATE.md): an independent
  fidelity and security review before the next step found defects in
  every reviewed M6.6 step; each finding's class becomes a standing gate.
- #42 CI liveness (harnesses/ci/ci_local.py, make ci-local): every M6.6
  commit had zero check runs; no check run on the head means no gate ran.
- #43 Reach census: piccolo's own "implemented" list was taken as
  fidelity; no corpus reached pcall/pairs/rawlen/collectgarbage.
- #44 Sabotage protocol: restore AND bump the mtime (#38 as written
  tested a stale build); a kill is not a catch; an independent set.
- #45 progress.py stamps a source digest at each gate tick (opt-in).
- #46 check_skills.py check 5: each lesson that amends a PLAYBOOK phase
  is cited by that phase's skills; the skills and prompts back-filled.
- #47 The input matrix gets rows for omitted options (two defects lived
  since M1 and M4 because every row passed -p and -oX -).
- #48 Scoped tolerances (normalize.py, diff_run.py: a tolerance fires
  only on its listed cases; STALE-TOLERANCE): an argument-number
  regression passed on 5,906 rows through an unscoped class.
- #49 UB-screened C-generated goldens (ORACLE-CHECKS.md): 14 golden
  rows came from signed int overflow.
- #50 scan_c_flaws.py: five rules (scanf-narrow-int,
  index-rewind-in-stride-loop, negation-to-unsigned, narrow-field-store,
  ctype-signed-char), a per-target ALLOC_FUNCS table, --inventory
  recursion; recall on M6.6's 22 C defects 1 -> 10 (12 with the
  inventory), +52 hits on the other 772 files, mostly real.
- #51 API-check oracle builds, path filters over oracle inputs,
  citations by revision and ID.
- PLAYBOOK 489 -> 399 lines, detail moved to three linked docs.

make -C porting-kit check-kit: OK (every self-test including the new
harnesses; 6 skills, 0 problems).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
kj299 pushed a commit that referenced this pull request Nov 14, 2026
… retrospective

The kit's CI template passes --src to `progress.py audit`, so that a
gate tick whose code has changed fails (LESSONS #45). nmap's workflow
never did, and STALE-TICK could fire only on a local run (LESSONS #57).

PLAN.md records that the IPv6-scans milestone merged with no CI run on
any of its commits, and what its retrospective changed in the kit.

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