VAITP Dataset

← Back to the dataset

CVE-2020-27351

Memory and file descriptor leaks in python-apt versions pre-GHSL-2020-170 update

  • CVSS 2.8
  • CWE-772 Missing Release of Resource after Effective Lifetime
  • Resource Management
  • Remote

Various memory and file descriptor leaks were found in apt-python files python/arfile.cc, python/tag.cc, python/tarfile.cc, aka GHSL-2020-170. This issue affects: python-apt 1.1.0~beta1 versions prior to 1.1.0~beta1ubuntu0.16.04.10; 1.6.5ubuntu0 versions prior to 1.6.5ubuntu0.4; 2.0.0ubuntu0 versions prior to 2.0.0ubuntu0.20.04.2; 2.1.3ubuntu1 versions prior to 2.1.3ubuntu1.1;

CVSS base score
2.8
Published
2020-12-10
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Missing Functionality
Category
Resource Management
Subcategory
Memory Leaks
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
python-apt
Fixed by upgrading
Yes

Solution

Update python-apt to version 2.1.3ubuntu1.1 or higher.

Vulnerable code sample

import tarfile

def extract_tarfile(tar_path, extract_path):
    tar = tarfile.open(tar_path, 'r')
    tar.extractall(path=extract_path)
    # Potential memory and file descriptor leak if tar is not closed properly
    # No explicit closing of the tarfile object

# Example usage
extract_tarfile('example.tar', './extracted')

Patched code sample

import tarfile

def extract_tarfile(tar_path, extract_path):
    try:
        with tarfile.open(tar_path, 'r') as tar:
            tar.extractall(path=extract_path)
    except Exception as e:
        print(f"An error occurred: {e}")
    finally:
        # Ensure that resources are released properly
        if 'tar' in locals():
            tar.close()

# Example usage
extract_tarfile('example.tar', './extracted')

Cite this entry

@misc{vaitp:cve202027351,
  title        = {{Memory and file descriptor leaks in python-apt versions pre-GHSL-2020-170 update}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2020},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2020-27351},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-27351/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.