VAITP Dataset

← Back to the dataset

CVE-2026-120499

Code injection in h5io ≤ 0.2.5 via crafted HDF5 nodes eval’d or imported.

  • CVSS 8.5
  • CWE-95
  • Input Validation and Sanitization
  • Local

h5io before 0.2.6 contains a code injection vulnerability in read_hdf5() that allows attackers to execute arbitrary code by supplying a crafted HDF5 file. Attackers can store Python code in a node titled timezone, which _triage_read() passes to eval() with builtins reachable, name an arbitrary module in class or custom-object nodes that _import_class() imports, or place pickled objects in pd_dataframe or pd_series nodes that pandas deserializes on read.

CVSS base score
8.5
Published
2026-11-05
OWASP
A03 Injection
Orthogonal defect classification
Interface
Code defect classification
Incorrect Interface
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Local
Impact
Arbitrary Code Execution
Affected component
h5io
Fixed by upgrading
Yes

Solution

Upgrade h5io to version 0.2.6 or later.

Vulnerable code sample

import h5py
import pandas as pd

def read_hdf5(path: str):
    """Read an HDF5 file and convert special nodes to Python objects."""
    with h5py.File(path, 'r') as f:
        result = {}
        for key in f.keys():
            node = f[key]
            if isinstance(node, h5py.Group):
                # VULNERABLE: eval on untrusted content
                if 'timezone' in node:
                    result[key] = eval(node['timezone'][()])
                elif 'class' in node:
                    result[key] = _import_class(node['class'][()])
                elif 'pd_dataframe' in node:
                    result[key] = pd.read_pickle(node['pd_dataframe'][()])
                else:
                    result[key] = dict(node)
            else:
                result[key] = node[()]
        return result

def _import_class(spec: str):
    """Import a class given a full module path."""
    mod_name, cls_name = spec.rsplit('.', 1)
    mod = __import__(mod_name, fromlist=[cls_name])
    return getattr(mod, cls_name)

Patched code sample

import h5py
import pandas as pd
import ast
import importlib

def read_hdf5(path: str):
    """Read an HDF5 file and convert special nodes to Python objects."""
    with h5py.File(path, 'r') as f:
        result = {}
        for key in f.keys():
            node = f[key]
            if isinstance(node, h5py.Group):
                # FIX: safe literal evaluation instead of eval
                if 'timezone' in node:
                    result[key] = ast.literal_eval(node['timezone'][()])
                elif 'class' in node:
                    result[key] = _import_class(node['class'][()])
                elif 'pd_dataframe' in node:
                    # FIX: avoid pandas pickle deserialization
                    result[key] = pd.read_json(node['pd_dataframe'][()], orient='split')
                else:
                    result[key] = dict(node)
            else:
                result[key] = node[()]
        return result

def _import_class(spec: str):
    """Import a class given a full module path."""
    mod_name, cls_name = spec.rsplit('.', 1)
    mod = importlib.import_module(mod_name)
    return getattr(mod, cls_name)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026120499,
  title        = {{Code injection in h5io ≤ 0.2.5 via crafted HDF5 nodes eval’d or imported.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-120499},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-120499/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.