Repository navigation
M4 — ICMP back-fill for the SYN and flag scans (core::icmp_quote) - #57
Merged
Merged
Conversation
Backlog #2's last sub-slice. An ICMP destination-unreachable (type 3) or time-exceeded (type 11) quotes the packet that provoked it, so it can be matched back to the probe it answers. The UDP scan used this from the start; core::icmp_quote generalizes the quote parser to TCP and shares it with -sS and all six flag scans. This matters most for -sF/-sN/-sX/-sM, whose no-response default is open|filtered: without ICMP matching those scans could never report a port as filtered at all. core::icmp_quote (new) - parse_icmp_error yields the three addresses that are NOT interchangeable: the sender (may be a router), the quoted source (must be us), and the quoted destination (the host the verdict belongs to). from_target is then just sender == quoted_dst. - icmp_to_reason ports portreasons.cc, including that codes 9/10/13 are three distinct reasons in nmap, not one "admin-prohibited". - Also now the single home of ipv4_offset, which all three matchers had their own copy of — closing the "DRY the scan matchers" follow-up. core::synscan - match_tcp_icmp_error, shared with the flag scans since the quote rules are identical. The quote contains our original packet, so unlike a RST (which reflects no sequence of ours) the encoded sequence IS present and is verified, as the C compares th_seq to probe->tcpseq(). - SynReply/FlagReply/UdpReply now carry the reason they matched on, so a filtered port reports the specific code rather than "no-response". sys::group - MatchParams groups the per-scan match constants and carries our source address; the SYN and flag BPF filters now also admit ICMP, without which the errors never reach the matcher. Two findings from reading the C, one of which corrects this port: 1. The #55 ledger claimed attributing an ICMP error to the quoted destination was "stricter than the C". That was wrong: the C does the same (findHost(&encaps_hdr.dst), then from_target against the outer source). Corrected in DIVERGENCES.md — it is a structural note, not a hardening. The ledger ships as release notes, so accuracy matters. 2. A real gap in our own UDP path: the C requires the quoted packet's source to be our address ("If it didn't come from us, we don't care") and we never checked it. All three scans now enforce it, which is why every match context carries our_ip. Gates: fmt + clippy (default and all-features) on 1.97.0; 335 core tests; miri clean; unsafe-audit 11/11 documented, 0 undocumented; fuzz match_syn 5.0M / match_udp 5.7M / match_flag 1.8M / services_probes_parse 290k runs, no crashes; all four privileged e2e suites pass as root. Ledger: synscan-icmp-match-deferred and flagscan-icmp-match-deferred resolved; udpscan-icmp-attributed-to-quoted-destination corrected; new icmp-quote-requires-our-source, icmp-quote-verifies-our-sequence, icmp-reason-fidelity, icmp-bpf-widened-for-tcp-scans. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
kj299
marked this pull request as ready for review
July 25, 2026 14:07
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backlog #2's last sub-slice. An ICMP destination-unreachable (type 3) or time-exceeded (type 11) quotes the packet that provoked it, so it can be matched back to the probe it answers. The UDP scan used this from the start;
core::icmp_quotegeneralizes the quote parser to TCP and shares it with-sSand all six flag scans.This matters most for
-sF/-sN/-sX/-sM, whose no-response default isopen|filtered: without ICMP matching those scans could never report a port as filtered at all.What lands
core::icmp_quote(new) —parse_icmp_erroryields the three addresses that are not interchangeable:senderquoted_srcquoted_dstfrom_targetis then justsender == quoted_dst. Also portsportreasons.cc: icmp_to_reason, and becomes the single home ofipv4_offset, which all three matchers previously carried their own copy of — closing the "DRY the scan matchers" follow-up.core::synscan—match_tcp_icmp_error, shared with the flag scans since the quote-matching rules are identical. The quote contains our original packet, so unlike a RST (which reflects no sequence of ours) the encoded sequence is present and is verified, as the C comparesth_seqtoprobe->tcpseq(). That makes a flag scan's ICMP path better authenticated than its RST path.The three reply structs now carry the reason they matched on, so a filtered port reports the specific code instead of a generic
no-response.sys::group—MatchParamsgroups the per-scan match constants and carries our source address; the SYN and flag BPF filters now also admit ICMP, without which the errors never reach the matcher at all.Two findings from reading the C — one corrects this port
1. A ledger claim in #55 was wrong, and I've fixed it. That PR said attributing an ICMP error to the quoted destination was "stricter than the C". It isn't — the C does the same thing (
findHost(&encaps_hdr.dst), thenfrom_targetagainst the outer source).DIVERGENCES.mdnow records it as a structural note with an explicit correction. The ledger ships as release notes, so an overstated security claim is worth fixing directly.2. A real gap in our own UDP path. The C requires the quoted packet's source to be our address — "If it didn't come from us, we don't care." We never checked it. The port/attempt encoding limited the impact, but a crafted error quoting a third party's packet could be accepted. All three scans now enforce it, which is why every match context carries
our_ip.Verification
core::icmp_quote: 8 unit tests, including every truncation of a valid frame, non-quoting ICMP types, a non-IPv4 quote, and a sub-minimum IHL.-sFshown goingopen|filtered→filteredwith and without the error, which is the back-fill's whole point..3does not land on.2, and only.3gets an ICMP reason.Gates
fmt + clippy (default and all-features) on pinned 1.97.0 · 335 core tests · miri clean · unsafe-audit 11/11 documented, 0 undocumented (no new unsafe) · fuzz
match_syn5.0M /match_udp5.7M /match_flag1.8M /services_probes_parse290k runs, no crashes · all four privileged e2e suites pass as root. Rebased onto master after #56 merged and re-verified.Ledger
synscan-icmp-match-deferredandflagscan-icmp-match-deferredresolved;udpscan-icmp-attributed-to-quoted-destinationcorrected; newicmp-quote-requires-our-source,icmp-quote-verifies-our-sequence,icmp-reason-fidelity,icmp-bpf-widened-for-tcp-scans.Backlog #2 is now complete. Next in the plan of record is backlog #3 — M5, OS detection (
osscan2+nmap-os-db, IPv6FPEngine).🤖 Generated with Claude Code
https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
Generated by Claude Code