scipy.io.netcdf_file CWE-770 unbounded allocation PoC

Proof-of-concept file for a huntr Model Format Vulnerability report against scipy (scipy.io.netcdf_file, the classic NetCDF-3 reader).

evil.nc is a 48-byte NetCDF-3 file declaring a single global attribute (evil) of type NC_DOUBLE with an element count of 0x7FFFFFFF (2,147,483,647) - no dimensions, no variables, and no actual attribute data bytes present in the file.

_read_att_values() (scipy/io/_netcdf.py:754-762) reads the declared element count n and type size directly from the file, computes count = n*size (up to ~17.2GB for NC_DOUBLE), and immediately calls self.fp.read(int(count)) - no check against the file's actual remaining size before attempting the read/allocation.

Verified live (scipy 1.18.0) under a 500MB ulimit -v cap:

$ python3 -c "import scipy.io; scipy.io.netcdf_file('evil.nc')"
MemoryError

Reachable via the public, documented scipy.io.netcdf_file(filename) constructor - the standard way to open a NetCDF-3 file with scipy.

Impact: Denial of Service - an attacker who can supply or influence an untrusted .nc file can force unbounded memory allocation from a file as small as 48 bytes.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support