What HDF5 is and why it's used
HDF5 is a hierarchical binary format built for large scientific and machine-learning datasets. It supports nested groups, embedded metadata, configurable compression, and external or virtual links between files — flexibility that makes it a workhorse in data pipelines, and largely invisible as a security concern because it 'looks like' a plain data file.
Where the risk actually lives
That flexibility is the issue. HDF5 supports pluggable compression and filter pipelines — loading a file can trigger a filter plugin to run, which is a code-execution surface if dynamic filter loading is enabled and the file comes from somewhere untrusted. External and virtual dataset links can point outside the directory you expect, a path-traversal-style risk if link targets aren't validated. Malformed files can crash or hang a parser, which is a denial-of-service vector in any pipeline that ingests files automatically. And large embedded attributes are an easy place to smuggle unexpected data past a casual manual review.
Practical mitigations
Treat any HDF5 file from outside your organization as untrusted input, the same way you'd treat an uploaded executable. Disable dynamic filter or plugin loading where your library allows it. Parse untrusted files in a sandboxed, least-privilege process rather than your main application context. Validate or allowlist external link paths instead of following them blindly. Keep your HDF5 library (and h5py, if you're in Python) patched, and don't skip malware scanning on data files just because they aren't `.exe`.