-
Notifications
You must be signed in to change notification settings - Fork 38
/
tarfile-extractall-traversal.yaml
41 lines (39 loc) · 1.37 KB
/
tarfile-extractall-traversal.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
37
38
39
40
41
rules:
- id: tarfile-extractall-traversal
message: >-
Possible path traversal through `tarfile.open($PATH).extractall()` if the source tar is controlled by an attacker
languages: [python]
severity: ERROR
metadata:
category: security
cwe: "CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')"
subcategory: [vuln]
confidence: MEDIUM
likelihood: MEDIUM
impact: MEDIUM
technology: [--no-technology--]
description: "Potential path traversal in call to `extractall` for a `tarfile`"
references:
- https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall
patterns:
- pattern-either:
- pattern: |
with tarfile.open(...) as $TAR:
...
$TAR.extractall(...)
- pattern: |
tarfile.open(...).extractall(...)
- pattern: |
$TAR = tarfile.open(...)
...
$TAR.extractall(...)
- pattern-not: |
with tarfile.open(...) as $TAR:
...
$TAR.extractall(..., members=$MEMBERS, ...)
- pattern-not: |
tarfile.open(...).extractall(..., members=$MEMBERS, ...)
- pattern-not: |
$TAR = tarfile.open(...)
...
$TAR.extractall(..., members=$MEMBERS, ...)