
Go probe that reproduces the Linux IPv4 checksum-offload bug PwnEscape on a prepared TAP, injecting crafted virtio headers and verifying the out-of-bounds fragment header copy.
Go probe for the Linux IPv4 checksum-offload bug known as PwnEscape. It attaches to a TAP you already prepared and checks whether the host fragmenter trusts an IPv4 header rewritten by skb_checksum_help.
The probe handles packet injection and capture. scripts/setup.sh prepares the lab interfaces, sysctl settings, and nftables rule inside the pwnesc network namespace. scripts/teardown.sh removes the lab.
On a kernel that still completes a partial checksum before reading ihl (reproduced here on 6.18.54; fixed in 6.18.57):
csum_start=22 is accepted. Two VID-0 tags are then stripped (14+4+4), so the checksum write lands on the IPv4 version/IHL byte.0x45 to 0x4f. The fragmenter uses a 60-byte header.-head 8, the linear head is 28 bytes, so the 60-byte header copy reads 32 bytes past skb_headlen into the output fragments' IPv4 options.This exercises the disclosure primitive described in PWN.AI's PwnEscape write-up. With CONFIG_INIT_ON_ALLOC_DEFAULT_ON, fresh slab tailroom may appear as zeroes in the copied bytes.
ihlip, nft, sysctlnf_conntrack and nf_defrag_ipv4/dev/net/tunFrom the repository directory on the host:
go build -o poc .
sudo ./scripts/setup.sh
sudo ip netns exec pwnesc ./poc
The probe opens pwntap with IFF_TAP|IFF_NO_PI|IFF_VNET_HDR and captures output on pwnv1. Reserve pwntap for the probe. The nftables ct rule activates conntrack defragmentation, and pwnv0 uses MTU 200 to fragment the reassembled datagram again on output.
A successful header check prints verify: first byte 0x4f ihl=15. The probe then reports the output fragments, their IPv4 options, and the bytes copied past the linear head.
-head (default 8): offset-0 fragment payload in bytes; a multiple of 8 from 8 through 40. The expected copy past the linear head is 40 - head bytes.-rest (default 400): completing-fragment payload in bytes; at least 16.-spray (default 0): number of same-sized frames allocated immediately before the offset-0 fragment.-spray-fill (default 0xee): byte used to fill those frames.-page: use a page_frag head, whose tail can contain skb metadata. The default is a slab head.-skip-verify: go directly to the fragmented-datagram check.PWN_TAP selects the TAP interface (default pwntap). PWN_CAP selects the capture interface (default pwnv1). The setup script uses these default names.
After the probe finishes, exit any shells in pwnesc and run from the host:
sudo ./scripts/teardown.sh
This deletes pwnesc along with its interfaces, ip pwn nftables table, and namespace-local sysctl settings.