contrib.dlint.dlint-equivalent.insecure-zipfile-use

profile photo of returntocorpreturntocorp
Author
221
Download Count*

The Python 'zipfile' extract|extractall functions are vulnerable to arbitrary file overwrites

Run Locally

Run in CI

Defintion

rules:
  - id: insecure-zipfile-use
    message: The Python 'zipfile' 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/DUO112.md
      category: security
      technology:
        - python
      references:
        - https://github.com/dlint-py/dlint/blob/master/docs/linters/DUO112.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: |
          $ZF = zipfile.ZipFile(...)
          ...
          $ZF.extract(...)
      - pattern: |
          $ZF = zipfile.ZipFile(...)
          ...
          $ZF.extractall(...)