# DF-3261 verification

Kernel: DragonFly dfbsd 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

## Bottom line

ipfw_check_ioc_rule never validates the set byte: rules installed via the same IP_FW_ADD sockopt the CLI uses with set=40 and set=200 are accepted (set subsystem is defined 0..31). ipfw -S list shows them as set 40 and set 200; ipfw set disable 8 instantly stops ALL THREE test rules (sets 40, 200 and the legal 8) from counting packets - on x86 the 1 << 40 and 1 << 200 classification-time shifts mask to 1 << 8 (ip_fw2.c:3601 UB) - and ipfw set move 40 to 0 refuses with invalid source number 40, so the administrator can never correctly administer such rules through the set API. Root-installed policy confusion plus C undefined behavior; no memory unsafety on x86.

## Kernel references
- sys/net/ipfw/ip_fw2.c:4518
- sys/net/ipfw/ip_fw2.c:3601

## Exploit chain
(none: availability/correctness finding; no privilege chain)

## Fix

reject set >= 31 at install; combined fixed kernel: addset 40 is refused with invalid set while legal sets still install

See fix.diff in this directory (git-apply-able against the read-only sys/
tree; applied only inside the disposable verification guest).

## Reproduction

build: guest: cc -O -o addset addset.c (raw IP_FW_ADD with exact ipfw_ioc_rule layout)

run: guest: kldload ipfw + staged allow rule; addset 40 1000; addset 200 1001; addset 8 1002; ping; ipfw set disable 8; ping; ipfw show

expected: sets 40/200 install; set disable 8 freezes all three rules counters; set move 40 rejected

## Notes on the PoC (what changed vs the finding sketch)

three layout fixes: cmd words start at byte 60 (15 header words, cmd[1] embedded), total = 4*(15+cmd_len), and the opcode values are the enum ordinals (O_VIA=19, O_COUNT=46), not header line numbers

## Fix status (batch validation)
Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest `make -j6 nativekernel KERNCONF=X86_64_GENERIC` completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.
