forked from trailofbits/semgrep-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pickles-in-numpy.yaml
34 lines (33 loc) · 1.05 KB
/
pickles-in-numpy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
rules:
- id: pickles-in-numpy
message: >-
Functions reliant on pickle can result in arbitrary code execution.
Consider using fickling or switching to a safer serialization method
languages: [python]
severity: ERROR
metadata:
category: security
cwe: "CWE-502: Deserialization of Untrusted Data"
subcategory: [vuln]
confidence: MEDIUM
likelihood: MEDIUM
impact: HIGH
technology: [numpy]
description: "Potential arbitrary code execution from `NumPy` functions reliant on pickling"
references:
- https://blog.trailofbits.com/2021/03/15/never-a-dill-moment-exploiting-machine-learning-pickle-files/
patterns:
- pattern: numpy.load(..., allow_pickle=$VALUE, ...)
- pattern-not: numpy.load("...", ...)
- pattern-not: numpy.load(..., file="...", ...)
- metavariable-pattern:
metavariable: $VALUE
patterns:
- pattern-not: |
False
- pattern-not: |
[]
- pattern-not: |
None
- pattern-not: |
""