Skip to content

Heap Buffer Overflow in Crypto_AOS_ProcessSecurity Function

Critical
jlucas9 published GHSA-7g6g-9gj4-8c68 Mar 17, 2025

Package

No package listed

Affected versions

<= 1.3.3

Patched versions

None

Description

Summary

A critical heap buffer overflow vulnerability was identified in the Crypto_AOS_ProcessSecurity function of CryptoLib. This vulnerability allows an attacker to trigger a Denial of Service (DoS) or potentially execute arbitrary code (RCE) by providing a maliciously crafted AOS frame with an insufficient length.

Details

The vulnerability lies in the function Crypto_AOS_ProcessSecurity, specifically during the processing of the Frame Error Control Field (FECF). The affected code attempts to read from the p_ingest buffer at indices current_managed_parameters_struct.max_frame_size - 2 and current_managed_parameters_struct.max_frame_size - 1 without verifying if len_ingest is sufficiently large. This leads to a heap buffer overflow when len_ingest is smaller than max_frame_size.

Vulnerable Code:

if (current_managed_parameters_struct.has_fecf == AOS_HAS_FECF)
{
    uint16_t received_fecf =
        (((p_ingest[current_managed_parameters_struct.max_frame_size - 2] << 8) & 0xFF00) |
         (p_ingest[current_managed_parameters_struct.max_frame_size - 1] & 0x00FF));
}

Root Cause:
The code does not validate len_ingest against max_frame_size before accessing the buffer, resulting in out-of-bounds memory access.

PoC

To reproduce the vulnerability, provide the following input to Crypto_AOS_ProcessSecurity:

char* test_aos_secured_h = "403030303030303030FF35DF4008EF"; // 15 bytes

This input triggers an out-of-bounds read when max_frame_size is set to 1786 bytes.

ASan Output

The vulnerability was detected through AddressSanitizer (ASan), showing the following error:

==197671==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x502000017628 at pc 0x7caa86abcbde bp 0x7ffe85c3b930 sp 0x7ffe85c3b920
READ of size 1 at 0x502000017628 thread T0
#0 0x7caa86abcbdd in Crypto_AOS_ProcessSecurity
/home/mirko/Downloads/CryptoLib/src/core/crypto_aos.c:1082

#1 0x613c0ce1862f in main

Impact

  • Denial of Service (DoS): The application may crash due to the out-of-bounds memory access.
  • Remote Code Execution (RCE): If the overflow is exploited to manipulate the heap, arbitrary code execution may be possible.

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
High
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:H/I:H/A:H

CVE ID

CVE-2025-29911

Weaknesses

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.

Out-of-bounds Write

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

Credits