VYPR
Unrated severityNVD Advisory· Published Aug 30, 2024· Updated Sep 3, 2024

Double-free in libpcap before 1.10.5 with remote packet capture support.

CVE-2023-7256

Description

A double-free vulnerability in libpcap's rpcap code occurs when sock_initaddress() and its caller both call freeaddrinfo() on the same memory block.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

A double-free vulnerability in libpcap's rpcap code occurs when `sock_initaddress()` and its caller both call `freeaddrinfo()` on the same memory block.

Vulnerability

In affected versions of libpcap, the internal function sock_initaddress() calls getaddrinfo() and possibly freeaddrinfo() but does not clearly indicate to the caller whether freeaddrinfo() still needs to be called after the function returns. This ambiguity leads to a double-free vulnerability when both the function and its caller attempt to free the same addrinfo structure. The issue is present in the remote packet capture (rpcap) subsystem. Affected versions include those prior to the commits that changed the return type of sock_initaddress() (e.g., prior to commit 262e4f34979872d822ccedf9f318ed89c4d31c03). [1][2]

Exploitation

An attacker must be able to trigger the rpcap setup sequence in a way that exercises the double-free code path. This may require network access to initiate a remote capture session. The vulnerability is triggered when sock_initaddress() returns without freeing the addrinfo list, but the caller also calls freeaddrinfo() based on a previous convention. The double-free occurs during the network address resolution phase of setting up a remote packet capture connection. [1][2]

Impact

A double-free of a heap-allocated addrinfo structure can corrupt the heap, leading to a denial of service (application crash) or potentially arbitrary code execution in the context of the process using libpcap. The exact impact depends on the heap allocator implementation and the application. The vulnerability is rated with a CVSS v3.1 score of 7.5 (High) due to potential for remote code execution or crash. [1][2]

Mitigation

The fix was committed to the libpcap repository in commits 2aa69b04d8173b18a0e3492e0c8f2f7fabdf642d and 262e4f34979872d822ccedf9f318ed89c4d31c03. These change sock_initaddress() to return the addrinfo pointer directly (or NULL on failure), making the ownership clear to the caller. Users should upgrade to a version of libpcap containing these commits. No workaround is publicly available. [1][2]

AI Insight generated on May 26, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

22

Patches

0

No patches discovered yet.

Vulnerability mechanics

Root cause

"The internal function sock_initaddress() does not clearly indicate to its caller whether freeaddrinfo() still needs to be called, leading to a potential double-free vulnerability."

Attack vector

An attacker can trigger this vulnerability by initiating a remote packet capture setup. This involves calling the sock_initaddress() function, which in turn calls getaddrinfo() and potentially freeaddrinfo(). If the caller also attempts to free the same memory block allocated by getaddrinfo(), a double-free condition occurs. This can lead to a crash or other unintended behavior.

Affected code

The vulnerability exists within the sock_initaddress() function in libpcap. This function is called by various remote capture-related functions, including rpcap_remoteact_getsock(), pcap_startcapture_remote(), rpcap_setup_session(), and pcap_remoteact_accept_ex(). The patch modifies these calling sites to correctly handle the return value of sock_initaddress().

What the fix does

The patch modifies the sock_initaddress() function to consistently return a pointer to the allocated addrinfo structures or NULL. This change clarifies the ownership of the allocated memory, ensuring that the caller can correctly manage its lifecycle and avoid calling freeaddrinfo() multiple times on the same memory block. The return value is now checked by the calling functions to determine if the address initialization was successful.

Generated on Jun 4, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

2

News mentions

0

No linked articles in our index yet.