-
Notifications
You must be signed in to change notification settings - Fork 38
/
pickles-in-keras.yaml
36 lines (35 loc) · 1.53 KB
/
pickles-in-keras.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
35
36
rules:
- id: pickles-in-keras
message: >-
Keras' load_model function may result in arbitrary code execution:
- It can load vulnerable pickled models
- It can load an hdf5 model that contains a lambda layer with arbitrary code
that will be executed every time the model is used (loading, training, eval)
Note: Keras loading with the built-in file format should be safe as long as checks are not disabled.
languages: [python]
severity: ERROR
metadata:
category: security
cwe: "CWE-502: Deserialization of Untrusted Data"
subcategory: [vuln]
confidence: MEDIUM
likelihood: MEDIUM
impact: HIGH
technology: [keras]
description: "Potential arbitrary code execution from Keras' load_model function"
references:
- https://blog.trailofbits.com/2021/03/15/never-a-dill-moment-exploiting-machine-learning-pickle-files/
patterns:
- pattern-either:
- patterns:
- pattern: keras.models.load_model(...)
- pattern-not: keras.models.load_model("...", ...)
- patterns:
- pattern: tensorflow.keras.models.load_model(...)
- pattern-not: tensorflow.keras.models.load_model("...", ...)
- patterns:
- pattern: keras.saving.load_model(...)
- pattern-not: keras.saving.load_model("...", ...)
- patterns:
- pattern: tensorflow.keras.saving.load_model(...)
- pattern-not: tensorflow.keras.saving.load_model("...", ...)