Skip to content

Pre-authentication heap buffer overflow in libesl `Content-Length` parsing.

Critical
andywolk published GHSA-g597-9fgg-ghg9 Jun 3, 2026

Package

FreeSWITCH (C)

Affected versions

<= 1.11.0

Patched versions

>= 1.11.1

Description

Summary

esl_recv_event() parses Content-Length with atol() and passes the result straight to malloc(len + 1) with no sign or magnitude check. A malicious or man-in-the-middle ESL peer can send a frame with a negative Content-Length to corrupt the heap of, or crash, any process linked against libesl, before the client has authenticated to that peer.

Impact

  • Content-Length: -1 - malloc(0) succeeds and body[len] = '\0' underwrites one byte at body[-1]. The body-read loop then copies attacker-controlled bytes that the peer queued after the header into the zero-byte allocation, producing a heap buffer overflow with attacker-controlled length and contents.
  • Content-Length: -2 and lower - len + 1 underflows when converted to size_t, malloc returns NULL, and the following statement dereferences the NULL pointer. The connecting process crashes.

RCE has not been demonstrated.

Affected configurations

fs_cli, mod_esl, mod_hash, and any third-party application linked against libesl. The outbound socket dialplan application in mod_event_socket is not affected - it uses its own ESL implementation.

Attack prerequisites

ESL is a cleartext protocol meant for use on a trusted control plane (loopback or a private management network); transport confidentiality and integrity are the operator's responsibility. Within that boundary, this bug lets the ESL peer — or anyone with reach to the same segment - corrupt the heap of, or crash, a connecting libesl client before the client authenticates. No credentials or prior interaction are required; the malicious frame is the first event the client reads.

Workarounds

No reliable workaround. Operators who cannot upgrade should restrict which hosts libesl clients (fs_cli, mod_esl, mod_hash, third-party tools) are configured to connect to, and keep the control-plane network unreachable from less-trusted hosts.

Fix

Reject Content-Length values that are negative or above an ESL_MAX_CONTENT_LENGTH cap (16 MiB), replace the assert on the malloc result with a runtime check, and destroy the partially-built event on the new error paths so the handle is left in a clean state.

Credit

Adam Bedard, Security Researcher.

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H

CVE ID

CVE-2026-49840

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Heap-based Buffer Overflow

A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). Learn more on MITRE.

Signed to Unsigned Conversion Error

The product uses a signed primitive and performs a cast to an unsigned primitive, which can produce an unexpected value if the value of the signed primitive can not be represented using an unsigned primitive. Learn more on MITRE.

Out-of-bounds Write

The product writes data past the end, or before the beginning, of the intended buffer. Learn more on MITRE.

Credits