Heap-buffer-overflow in fixup_pcap_pkthdr in libpcap

libpcap Updated 02 Oct 2025

Summary

09/07/2022
MEDIUM
Yes i
Medium
Not published

OSV-2022-551: Heap-buffer-overflow in fixup_pcap_pkthdr. Affects libpcap across 2 version ranges.

>= 854614423a5b790aaac73131591cb7c716157241, < a774407d41419bc8f3069b70e9d9be26c82f0f70 >= b4eeafb93955807464d8bb9327772fb217fcdd9a, < e2c0fd75e48a3cbf1bf48b8afe28fff50d8e0877

Fixed in e2c0fd75e48a3cbf1bf48b8afe28fff50d8e0877. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

libpcap is a widely used library for capturing network packets. It provides a portable framework for network traffic capture and analysis. The library is commonly used by network monitoring tools, packet sniffers, and network intrusion detection systems. Unfortunately, a heap-buffer-overflow vulnerability has been discovered in the fixup_pcap_pkthdr function of libpcap.

Vulnerability Detail

The heap-buffer-overflow vulnerability in fixup_pcap_pkthdr can lead to a read access violation, potentially resulting in a crash or arbitrary code execution. The vulnerability occurs when processing pcap packet headers, specifically during the pcap_next_packet and pcap_offline_read functions. An attacker could exploit this vulnerability by crafting a malicious pcap file or by sending specially crafted packets to a vulnerable application that uses libpcap. Successful exploitation could allow the attacker to execute arbitrary code or cause a denial-of-service condition.

How To Fix

Minimum fixed version

e2c0fd75e48a3cbf1bf48b8afe28fff50d8e0877

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, developers can implement input validation and boundary checks when processing pcap packet headers. By ensuring that the packet header sizes are within expected limits, the risk of triggering the heap-buffer-overflow vulnerability can be reduced. Here is an example of how input validation can be implemented in C:

#include <pcap.h>

int main() {
    pcap_t *handle;
    char errbuf[PCAP_ERRBUF_SIZE];

    handle = pcap_open_offline("capture.pcap", errbuf);
    if (handle == NULL) {
        printf("Error opening pcap file: %s\n", errbuf);
        return 1;
    }

    struct pcap_pkthdr header;
    const u_char *packet;

    while (packet = pcap_next(handle, &header)) {
        if (header.len > MAX_PACKET_SIZE) {
            printf("Invalid packet size: %u\n", header.len);
            continue;
        }

        // Process the packet
    }

    pcap_close(handle);
    return 0;
}

Conclusion

The heap-buffer-overflow vulnerability in fixup_pcap_pkthdr in libpcap can have serious consequences, including crashes and potential code execution. It is crucial to update the libpcap library to a fixed version and regularly patch all software components to mitigate the risk of known vulnerabilities. Implementing input validation and boundary checks can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for libpcap →

Share this vulnerability

FAQ

libpcap is a library used for capturing network packets. It provides a portable framework for network traffic capture and analysis.

The heap-buffer-overflow vulnerability in fixup_pcap_pkthdr can lead to a crash or arbitrary code execution. An attacker could exploit this vulnerability to gain control over a vulnerable application or cause a denial-of-service condition.

To fix this vulnerability, update the libpcap library to a version that includes the fix. Application developers should also regularly update and patch all software components to mitigate the risk of known vulnerabilities.

As a temporary workaround, developers can implement input validation and boundary checks when processing pcap packet headers. By ensuring that the packet header sizes are within expected limits, the risk of triggering the vulnerability can be reduced.

You can find more information about this vulnerability in the OSS-Fuzz report: [link to OSS-Fuzz report]

Related vulnerabilities

Recent vulnerabilities recorded for libpcap.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

e2c0fd75e48a3cbf1bf48b8afe28fff50d8e0877

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback