Skip to content

Insecure Deserialization in NumPy

Description

Functions reliant on pickle can result in arbitrary code execution. Consider using a safer serialization method.

Examples

Insecure Code

python
numpy.load('example.pkl', allow_pickle=True)

Secure Code

python
import json; data = json.load(open('example.json'))

Remediation

Use a safer serialization method instead of pickle, such as JSON or MessagePack.

Rule Details

FieldValue
IDCODE-0498
CategoryDeserialization
SeverityCRITICAL
CWECWE-502
ConfidenceMEDIUM
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagspickle, deserialization
OWASPN/A

References