Skip to main content
Vulnerability Database/CVE-2024-26589

CVE-2024-26589: Linux Kernel Buffer Overflow Vulnerability

CVE-2024-26589 is a buffer overflow flaw in Linux Kernel that allows variable offset pointer arithmetic on PTR_TO_FLOW_KEYS causing out-of-bounds access. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-26589 Overview

CVE-2024-26589 is a Linux kernel vulnerability in the Berkeley Packet Filter (BPF) verifier. The flaw resides in how check_flow_keys_access() validates pointer arithmetic on PTR_TO_FLOW_KEYS. The verifier only checks fixed offsets and fails to reject variable offset ALU operations on this pointer type. A local attacker with the ability to load BPF programs can craft a program that performs arithmetic with an attacker-controlled variable offset against flow_keys, bypassing bounds enforcement and triggering out-of-bounds kernel memory access. The underlying weakness is classified as [CWE-119] improper restriction of operations within the bounds of a memory buffer.

Critical Impact

Local attackers can trigger out-of-bounds kernel memory access through crafted BPF programs, potentially leading to kernel memory corruption, denial of service, or privilege escalation.

Affected Products

  • Linux Kernel (multiple stable branches prior to the fix commits)
  • Distributions shipping affected kernel versions with unprivileged or privileged BPF enabled
  • Systems running the flow_dissector BPF program type

Discovery Timeline

  • 2024-02-22 - CVE-2024-26589 published to the National Vulnerability Database
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-26589

Vulnerability Analysis

The Linux kernel BPF verifier tracks pointer types to enforce memory safety at program load time. For pointers of type PTR_TO_FLOW_KEYS, access validation is performed by check_flow_keys_access(), which inspects only the fixed offset field of the register state. The verifier does not reject arithmetic that introduces a variable offset into the pointer. As a result, an attacker-controlled scalar can be added to a flow_keys pointer and later dereferenced without the variable component being included in the bounds check.

The commit message demonstrates a program that loads flow_keys from ctx+144 into r7, computes a scalar in r8 constrained by var_off=(0x0; 0x400), and adds r8 to r7. The verifier accepts the program, and when executed through bpf_prog_test_run_flow_dissector, it triggers a page fault at an address outside the valid flow_keys buffer.

Root Cause

The root cause is incomplete validation in check_flow_keys_access(). The function predates and does not account for variable-offset pointer arithmetic that other pointer kinds in the verifier explicitly prohibit or constrain. Because PTR_TO_FLOW_KEYS was not added to the list of pointer types that reject variable offset ALU operations, the verifier allows a dynamically computed offset to escape the bounded flow_keys region.

Attack Vector

Exploitation requires local access and the ability to load and execute a BPF program of type BPF_PROG_TYPE_FLOW_DISSECTOR, typically through the bpf() syscall and bpf_prog_test_run. An attacker constructs a program that performs a variable-offset addition on a PTR_TO_FLOW_KEYS register, then dereferences the result. The out-of-bounds load reaches kernel memory adjacent to the flow keys buffer, as shown in the crash trace through bpf_flow_dissect+0x15f/0x350 in net/core/flow_dissector.c.

The vulnerability manifests entirely within the kernel BPF verifier logic. See the upstream fix commits for the specific verifier changes that reject pointer arithmetic with variable offset on flow_keys.

Detection Methods for CVE-2024-26589

Indicators of Compromise

  • Kernel oops or page fault entries referencing bpf_flow_dissect or bpf_prog_run_pin_on_cpu in dmesg or /var/log/kern.log
  • Unexpected bpf() syscalls from unprivileged user contexts loading BPF_PROG_TYPE_FLOW_DISSECTOR programs
  • Kernel crash reports pointing to addresses in the ffffc9 range during flow dissector execution

Detection Strategies

  • Audit bpf() syscall activity using auditd rules targeting BPF_PROG_LOAD and BPF_PROG_TEST_RUN commands
  • Monitor for processes invoking BPF program loads outside expected administrative or observability tooling
  • Correlate kernel crash telemetry with the loading process to identify programs targeting the flow dissector path

Monitoring Recommendations

  • Enable kernel lockdown or set kernel.unprivileged_bpf_disabled=1 to limit the attack surface and generate denials when restricted
  • Forward kernel logs and auditd events to a centralized data lake for retrospective hunting on BPF verifier anomalies
  • Baseline normal BPF program load patterns per host and alert on deviations, especially from non-root users

How to Mitigate CVE-2024-26589

Immediate Actions Required

  • Apply the stable kernel updates containing the upstream fix commits that reject variable offset ALU on PTR_TO_FLOW_KEYS
  • Set sysctl kernel.unprivileged_bpf_disabled=1 to prevent unprivileged users from loading BPF programs
  • Inventory hosts that permit BPF program loading and prioritize patching for multi-tenant and container hosts

Patch Information

The fix was merged across multiple stable branches. Relevant commits include 1b500d5d6cec, 22c7fa171a02, 29ffa63f21bc, 4108b86e324d, and e8d3872b617c. Each commit adds a rejection path for variable-offset pointer arithmetic on flow_keys, producing the verifier error R<n> pointer arithmetic on flow_keys prohibited. Review the Kernel Git Commit 1b500d5 and the additional commits linked in the NVD entry to confirm backport coverage for your distribution kernel.

Workarounds

  • Disable unprivileged BPF by setting kernel.unprivileged_bpf_disabled=1 in /etc/sysctl.d/ and reloading
  • Restrict CAP_BPF and CAP_SYS_ADMIN to trusted service accounts only, especially inside containers
  • Where feasible, disable the flow dissector BPF attach point if not required by workload observability tooling
bash
# Configuration example
# Disable unprivileged BPF system-wide
echo 'kernel.unprivileged_bpf_disabled=1' | sudo tee /etc/sysctl.d/90-disable-unpriv-bpf.conf
sudo sysctl --system

# Verify current state
sysctl kernel.unprivileged_bpf_disabled

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.