upatch.dev

CVE-2026-98096

ipv6: sr: restore network header before routing and forwarding

Drops IPv6 packets where an extension header precedes a Segment Routing Header with segments left to mitigate CVE-2026-98096.

High 7.4Vetted

EPSS 0.5%: the estimated chance this CVE is exploited in the next 30 days, as of 24 Nov 2026.

At a glance

CVE-2026-98096 is a high (CVSS 7.4) vulnerability in the Linux kernel, published 25 September 2026. A vetted upatch, cve-2026-98096-srh-block, blocks it on running Linux machines with shirudo until the kernel is patched.

Severity
High 7.4 CVSS 3.1
Chance of exploitation
0.5% in the next 30 days (EPSS, 24 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-787
Affected software
Linux kernel
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

CVE-2026-98096, "ipv6: sr: restore network header before routing and forwarding", was published on 25 September 2026. ipv6_srh_rcv() in net/ipv6/exthdrs.c runs with skb->data pointing at the Segment Routing Header while skb_network_header() points at the fixed IPv6 header. When segments_left > 0, ipv6_srh_rcv() restored skb->data before routing by pushing sizeof(struct ipv6hdr) (40 bytes), assuming the SRH immediately followed the fixed IPv6 header. When another extension header such as a Hop-by-Hop options header precedes the SRH, skb_network_offset(skb) remains negative during ip6_route_input(), breaking __skb_flow_dissect() and causing downstream forwarding handlers such as ip6_forward() or sch_fragment() to pass the negative offset as an unsigned length, triggering out-of-bounds memory copies or buffer overflows.

Official description

In the Linux kernel, the following vulnerability has been resolved: ipv6: sr: restore network header before routing and forwarding ipv6_srh_rcv() runs with skb->data at the Segment Routing Header (SRH) while skb_network_header() points at the IPv6 header. When segments_left > 0, ipv6_srh_rcv() previously restored the skb->data position by pushing sizeof(struct ipv6hdr), assuming the SRH immediately followed the fixed IPv6 header. If another extension header (such as a Hop-by-Hop options header) precedes the SRH, skb_network_offset() remained negative. This led to two problems: 1. During ip6_route_input(), fib6_rules_early_flow_dissect() invokes __skb_flow_dissect() which passes the negative skb_network_offset() to flow dissection, breaking BPF and C flow dissector logic. 2. If forwarded via ip6_forward() or redirected via act_mirred, downstream handlers (like sch_fragment() or neighbour output) pass the negative offset as an unsigned length, triggering OOB memcpy or buffer overflows. Fix this by pushing -skb_network_offset(skb) before routing, ensuring skb_network_offset(skb) is 0 for route lookup / flow dissection as well as downstream forwarding. On the loopback path, pull skb_transport_offset(skb) to restore skb->data to the SRH before looping back.

Affected versions

Branch Bug added in Fixed in
5.10 4.10 5.10.271
5.15 4.10 5.15.222
6.1 4.10 6.1.189
6.6 4.10 6.6.158
6.12 4.10 6.12.111
6.18 4.10 6.18.53
7.2 4.10 7.2.7
mainline 4.10 7.3

Sources

More references from NVD (8)

Mitigation

It attaches to netfilter (IPv6 NF_INET_PRE_ROUTING), which runs in ipv6_rcv() before ip6_rcv_finish() and ipv6_srh_rcv(), and inspects incoming IPv6 packets whose nexthdr is an IPv6 extension header using bpf_dynptr_from_skb() and bpf_dynptr_slice(). When a packet carries an extension header chain in which a routing header of type IPV6_SRCRT_TYPE_4 (4) with segments_left > 0 appears after one or more preceding extension headers, or when an extension header chain cannot be parsed within 8 extension headers, the program returns NF_DROP (0). Packets without IPv6 extension headers return NF_ACCEPT (1) after reading the single nexthdr byte.

Side effects

  • Incoming IPv6 packets that place another extension header (such as Hop-by-Hop options or Destination options) before a Segment Routing Header with segments_left > 0, or that chain more than 8 IPv6 extension headers before a non-extension payload, are dropped at IPv6 pre-routing.
  • Incoming IPv6 packets without extension headers, with a Segment Routing Header immediately following the fixed IPv6 header, or with segments_left == 0 pass unchanged.
  • All IPv4 traffic passes unchanged.

Preemption model and cost

The program keeps no state: no maps, no shared or per-CPU data. It is correct under every preemption model, including preemptible RCU and PREEMPT_RT. It never runs on IPv4 packets; for ordinary IPv6 packets without extension headers it reads the single nexthdr byte via bpf_dynptr_slice() and compares it against six extension header protocol numbers. It walks the extension header chain (bounded to 8 headers) only when an IPv6 extension header is present.

The policy

87 lines of BPF C, attached at netfilter.

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>

#define NF_DROP			0
#define NF_ACCEPT		1
#define NEXTHDR_HOP		0
#define NEXTHDR_ROUTING		43
#define NEXTHDR_FRAGMENT	44
#define NEXTHDR_AUTH		51
#define NEXTHDR_DEST		60
#define NEXTHDR_MOBILITY	135
#define IPV6_SRCRT_TYPE_4	4
#define MAX_EXT_HDRS		8

char _license[] SEC("license") = "Dual BSD/GPL";

static __always_inline bool is_ipv6_ext(__u8 nh)
{
	return nh == NEXTHDR_HOP ||
	       nh == NEXTHDR_ROUTING ||
	       nh == NEXTHDR_FRAGMENT ||
	       nh == NEXTHDR_AUTH ||
	       nh == NEXTHDR_DEST ||
	       nh == NEXTHDR_MOBILITY;
}

SEC("netfilter")
int cve_2026_98096_srh_block(struct bpf_nf_ctx *ctx)
{
	struct bpf_dynptr ptr;
	struct ipv6_rt_hdr rthdr_buf, *rthdr;
	struct ipv6_opt_hdr ext_buf, *ext;
	__u8 nh_buf, *nhp;
	__u32 off = sizeof(struct ipv6hdr);
	__u8 nh;

	if (bpf_dynptr_from_skb((struct __sk_buff *)ctx->skb, 0, &ptr) < 0)
		return NF_ACCEPT;

	nhp = bpf_dynptr_slice(&ptr, offsetof(struct ipv6hdr, nexthdr), &nh_buf, sizeof(nh_buf));
	if (!nhp)
		return NF_ACCEPT;
	nh = *nhp;

	if (!is_ipv6_ext(nh))
		return NF_ACCEPT;

	for (int i = 0; i < MAX_EXT_HDRS; i++) {
		if (nh == NEXTHDR_ROUTING) {
			rthdr = bpf_dynptr_slice(&ptr, off, &rthdr_buf, sizeof(rthdr_buf));
			if (!rthdr)
				return NF_DROP;
			if (rthdr->type == IPV6_SRCRT_TYPE_4 && rthdr->segments_left > 0 && i > 0)
				return NF_DROP;
			nh = rthdr->nexthdr;
			off += ((__u32)rthdr->hdrlen + 1) << 3;
		} else if (nh == NEXTHDR_FRAGMENT) {
			nhp = bpf_dynptr_slice(&ptr, off, &nh_buf, sizeof(nh_buf));
			if (!nhp)
				return NF_DROP;
			nh = *nhp;
			off += 8;
		} else if (nh == NEXTHDR_AUTH) {
			ext = bpf_dynptr_slice(&ptr, off, &ext_buf, sizeof(ext_buf));
			if (!ext)
				return NF_DROP;
			nh = ext->nexthdr;
			off += ((__u32)ext->hdrlen + 2) << 2;
		} else if (nh == NEXTHDR_HOP || nh == NEXTHDR_DEST || nh == NEXTHDR_MOBILITY) {
			ext = bpf_dynptr_slice(&ptr, off, &ext_buf, sizeof(ext_buf));
			if (!ext)
				return NF_DROP;
			nh = ext->nexthdr;
			off += ((__u32)ext->hdrlen + 1) << 3;
		} else {
			return NF_ACCEPT;
		}
	}

	if (is_ipv6_ext(nh))
		return NF_DROP;

	return NF_ACCEPT;
}

Process

How this upatch was written, checked and reviewed, from the registry’s history.

  1. 25 Sept 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #24 openedAdd CVE-2026-98096: Drops IPv6 packets where an extension header precedes a Segment Routing Headerromanlab
  3. 25 Nov 2026MergeMerged #24romanlab
  4. 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)

No human review is recorded on GitHub for this upatch yet.

Evidence

With seg6_enabled active on loopback, the netfilter IPv6 pre-routing upatch dropped IPv6 packets with a Hop-by-Hop options header preceding a Segment Routing Header with segments_left > 0 while allowing ordinary IPv6 UDP traffic. The test kernel 7.4 already contains the upstream fix, so the unpatched run shows the packet reaching ipv6_srh_rcv() and being delivered.

Tested
25 Nov 2026
Target
Linux 7.4 with the fix and net.ipv6.conf.{all,lo}.seg6_enabled=1
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Machine
shirudo test VM
Results
StateHop-by-Hop + SRH (segments_left=1) UDP loopbackOrdinary IPv6 UDP loopback
Before loadingdelivereddelivered
Upatch loadeddropped at NF_INET_PRE_ROUTINGdelivered
After unloadingdelivereddelivered
tools-test.log Output of tools/test --setup on the shirudo test VM.
tools/test --setup, 2026-11-25T11:10:53Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-98096
  setup   done         no settings
  before  reached      IPv6 packet with Hop-by-Hop preceding SRH (segments_left=1) passed pre-routing
  loaded  blocked      IPv6 packet with Hop-by-Hop preceding SRH (segments_left=1) was dropped
  after   reached      IPv6 packet with Hop-by-Hop preceding SRH (segments_left=1) passed pre-routing
  PASS: reached before, blocked while loaded, reached again after

Use it

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-98096
Publish and roll out
shirudo bpm push build/packages/cve-2026-98096-1.0.0.bee oci://<registry>/<namespace>/cve-2026-98096 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-98096-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>