Skip to content

The Linux kernel bug that counted to 255 and started over

A too-small variable let crafted IPv6 packets slip past stateful firewall rules. The fix changes a single word of C.

Constructivist poster of a grid of small black squares on pale sage-green paper, one orange-red square slipped outside the grid through a gap at the top right
One square slips out of the grid.
On this pageJump to section

A packet arrived at a Linux firewall claiming to be ordinary DNS traffic, bound for UDP port 53. The firewall checked its records, found the flow allowed, and let it through. The packet's payload was delivered to UDP port 9999.

That mismatch is CVE-2026-139281, a flaw in the Linux kernel's Netfilter connection tracking that sat in the code for nearly 21 years. Red Hat rates it Critical, with a CVSS score of 9.1 out of 10. It took almost two decades for anyone to notice.

The flaw matters wherever a Linux machine is the firewall. Netfilter is the packet-filtering framework built into the kernel, and connection tracking, usually called conntrack, is the part that remembers each conversation so stateful rules can allow or block traffic based on the connection it belongs to. When conntrack misreads a packet, the rules enforce the wrong decision. An unauthenticated attacker on the network can send the crafted fragments. No login and no user action are needed.

How one byte breaks a firewall

The bug lives in the code that puts fragmented IPv6 packets back together, in a file called nf_conntrack_reasm.c. IPv6 lets a sender split a packet into fragments, and each fragment can carry a chain of extension headers, optional pieces of information placed in front of the actual data. A helper function called find_prev_fhdr() walks that chain to find one field: the position of the Next Header field before a Fragment header. It returns that position through an int pointer, but it kept its own working copy in a u8, an 8-bit variable that can only count to 255.

Most packets never push that field past byte 255, so the variable was big enough for two decades of ordinary traffic. A crafted packet with a long extension-header chain pushes it past the limit, and the stored value wraps around to a small number. During reassembly the kernel then writes to the wrong offset, overwriting a byte in the header chain. Conntrack parses a different set of addresses and ports from the ones the kernel uses for local delivery, and the firewall's record of the packet no longer matches the packet itself.

The patch is one line:

c
- u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
+ int prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);

The working copy becomes an int, matching the output argument and the other offset variables in the same code path. One word, u8 to int, and the wrap disappears.

Diagram of the two readings of one crafted IPv6 packet: the firewall records it as UDP port 53, DNS traffic, while the payload is actually delivered to UDP port 9999.
The firewall's record said DNS on port 53. The packet went to port 9999. Source.

Why it lasted 21 years

The patch's Fixes tag points at the commit that added the nf_conntrack subsystem, in Linux 2.6.15, released in January 2006. The code sat essentially untouched in this respect for almost 21 years, doing its job on every packet that stayed under the limit. The bug needed a packet shaped in a way no ordinary sender produces, and the shape went unnoticed until a researcher went looking.

The flaw's finder was Jérémy Jean, deputy head of the cryptography lab at ANSSI, France's national cybersecurity agency. He posted the patch to the Linux kernel mailing list on August 22, 2026. It was merged upstream on October 19, reached mainline in 7.4-rc1 on November 1, and the CVE record followed on November 30, more than three months after the code change went public.

One detail in the patch stands out. It carries the trailer "Assisted-by: Codex:gpt-5", crediting AI help. Neither the patch nor the upstream commit says what that assistance was: finding the bug, writing the fix, or checking it. The bug itself predates the tools by two decades either way.

Two scores for the same flaw

Red Hat and Canonical disagree about how bad this is, and the disagreement is instructive. Red Hat rates the flaw Critical at 9.1: an unauthenticated remote attacker bypassing stateful firewall rules, with high impact on confidentiality and integrity. Canonical rates it Medium at 6.9, judging that it has no impact on data confidentiality and only limited impact on system integrity.

The difference is what each vendor counts as the damage. Red Hat counts the bypass itself: traffic reaching services the rules were written to protect. Canonical counts what the bypass alone can do, which is reach a service, not read its data or take it over. The attacker still needs a vulnerable service on the other side of the firewall, and the flaw is classified as CWE-681, an incorrect conversion between numeric types, not a memory corruption bug. It lets traffic through. It does not hand over the machine.

Meanwhile the distributions are at different stages of the fix. The upstream stable kernels carry it: 5.10.275, 5.15.226, 6.1.193, 6.6.163, 6.12.119, 6.18.65, and 7.3.6. Red Hat shipped a kernel erratum for Red Hat Enterprise Linux 8 on December 3, and AlmaLinux published the matching update.

Debian lists its stable releases, bookworm and trixie, as vulnerable, with the fix in its development branches. Canonical marks the flaw as affecting Ubuntu kernel packages back to 16.04 LTS and is still evaluating which of its kernels need updates.

No attacks using the flaw have been confirmed in public sources, according to The Hacker News.

Check your kernel

Check the kernel version on any Linux host where IPv6 is enabled and a conntrack-based firewall is the protection, then compare it with the fixed releases for its branch. Install the distribution's update and reboot, since a kernel fix needs a restart to take effect. The hosts that matter most are the ones whose own firewall rules are the only barrier between a sensitive service and the outside world: perimeter firewalls, container hosts, and Kubernetes nodes.

Where patching has to wait, Red Hat's advice is to disable IPv6 on systems that do not need it. That removes the attack vector entirely, at the cost of all IPv6 connectivity on the machine, so it only makes sense where nothing on the box needs IPv6.

The audit question it leaves behind is simpler than the bug: how many other counters in the kernel are still eight bits wide?

Related reporting

More from grep.tips

All articles