Skip to content

Security: Unsafe np.load with allow_pickle=True in NPZFile#607

Open
tomaioo wants to merge 1 commit into
pynapple-org:mainfrom
tomaioo:fix/security/unsafe-np-load-with-allow-pickle-true-in
Open

Security: Unsafe np.load with allow_pickle=True in NPZFile#607
tomaioo wants to merge 1 commit into
pynapple-org:mainfrom
tomaioo:fix/security/unsafe-np-load-with-allow-pickle-true-in

Conversation

@tomaioo

@tomaioo tomaioo commented May 26, 2026

Copy link
Copy Markdown

Summary

Security: Unsafe np.load with allow_pickle=True in NPZFile

Problem

Severity: High | File: pynapple/io/interface_npz.py:L78

The NPZFile class uses np.load with allow_pickle=True, which can execute arbitrary code when loading maliciously crafted NPZ files. This is a known security vulnerability in NumPy's loading mechanism that allows for remote code execution through pickled objects.

Solution

Consider using allow_pickle=False if the use case permits, or implement strict validation of file contents before loading. If pickle support is required, document the security implications and consider adding warnings or sandboxing.

Changes

  • pynapple/io/interface_npz.py (modified)

The NPZFile class uses np.load with allow_pickle=True, which can execute arbitrary code when loading maliciously crafted NPZ files. This is a known security vulnerability in NumPy's loading mechanism that allows for remote code execution through pickled objects.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@tomaioo tomaioo requested a review from gviejo as a code owner May 26, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant