contrib.dlint.dlint-equivalent.insecure-tarfile-use

Author
221
Download Count*
The Python 'tarfile' extract|extractall functions are vulnerable to arbitrary file overwrites
Run Locally
Run in CI
Defintion
rules:
- id: insecure-tarfile-use
message: The Python 'tarfile' extract|extractall functions are vulnerable to
arbitrary file overwrites
languages:
- python
severity: WARNING
metadata:
source_rule_url: https://github.com/dlint-py/dlint/blob/master/docs/linters/DUO115.md
category: security
technology:
- python
references:
- https://github.com/dlint-py/dlint/blob/master/docs/linters/DUO115.md
owasp:
- A06:2017 - Security Misconfiguration
- A05:2021 - Security Misconfiguration
cwe:
- "CWE-22: Improper Limitation of a Pathname to a Restricted Directory
('Path Traversal')"
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
pattern-either:
- pattern: |
$TF = tarfile.TarFile(...)
...
$TF.extract(...)
- pattern: |
$TF = tarfile.TarFile(...)
...
$TF.extractall(...)
- pattern: |
$TF = tarfile.open(...)
...
$TF.extract(...)
- pattern: |
$TF = tarfile.open(...)
...
$TF.extractall(...)
- pattern: |
with tarfile.TarFile(...) as $TF:
...
$TF.extract(...)
- pattern: |
with tarfile.TarFile(...) as $TF:
...
$TF.extractall(...)
- pattern: |
with tarfile.open(...) as $TF:
...
$TF.extract(...)
- pattern: |
with tarfile.open(...) as $TF:
...
$TF.extractall(...)
Short Link: https://sg.run/Bk86