Security issues can be reported privately as described in the project README and when opening a new issue on the issue tracker. The Python security reporting guidelines are a good resource and its notes apply also to NumPy.
NumPy’s maintainers are not security experts. However, we are conscientious about security and experts of both the NumPy codebase and how it’s used. Please do notify us before creating security advisories against NumPy as we are happy to prioritize issues or help with assessing the severity of a bug. A security advisory we are not aware of beforehand can lead to a lot of work for all involved parties.
A user who can freely execute NumPy (or Python) functions must be considered to have the same privilege as the process/Python interpreter.
That said, NumPy should be generally safe to use on data provided by unprivileged users and read through safe API functions (e.g. loaded from a text file or .npy file without pickle support). Malicious values or data sizes should never lead to privilege escalation. Note that the above refers to array data. We do not currently consider for example f2py to be safe: it is typically used to compile a program that is then run. Any f2py invocation must thus use the same privilege as the later execution.
The following points may be useful or should be noted when working with untrusted data:
Exhausting memory can result in an out-of-memory kill, which is a possible denial of service attack. Possible causes could be:
.npy files) or carefully check the fields included for nested structured/subarray dtypes.np.dtype(user_string) or dtype=user_string.float64, float32, or int64 to reduce complexity.When working with non-trivial untrusted data, it is advisable to sandbox the analysis to guard against potential privilege escalation. This is especially advisable if further libraries based on NumPy are used since these add additional complexity and potential security issues.
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/security.html