Cloudanix VulnDB

CVE-2013-7459

Critical · 9.8

CVSS

9.8

EPSS

9.6%

Published

Feb 15, 2017

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Track

A flaw in a widely used but old programming library for encryption can allow an attacker to take complete control of a server over the network without needing a password.

Exploit Available
Exploitation
Remote Unauthenticated
Attacker needs
None
Complexity
Low
Impact
Remote Code Execution
Component
Library
Class
Memory Corruption
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

A heap-based buffer overflow vulnerability exists in the `ALGnew` function of the Python Cryptography Toolkit (pycrypto). By sending a specially crafted, overly long initialization vector (IV), a remote, unauthenticated attacker can overwrite heap memory. This can be leveraged to corrupt memory and achieve arbitrary code execution in the context of the application process using the library.

Why it matters to the business

Successful exploitation results in a complete compromise of the server running the affected application. An attacker can steal sensitive data, manipulate application data, disrupt service, and use the compromised system as a pivot point to attack other internal systems. Given the foundational nature of a cryptography library, the impact could be widespread across applications, leading to significant data breaches, operational outages, and loss of customer trust. The high CVSS score of 9.8 indicates a critical risk.

How an attack unfolds

An attacker identifies a network-exposed application that utilizes a vulnerable version of the pycrypto library for cryptographic operations. The attacker crafts a request containing a malicious, oversized initialization vector (IV) and sends it to the application. The vulnerable `ALGnew` function in pycrypto attempts to process this IV but fails to perform proper bounds checking, writing the oversized data past the intended buffer on the heap. This overwrites adjacent memory structures, allowing the attacker to hijack the application's control flow and execute arbitrary code on the underlying server.

How to fix it

The pycrypto library is unmaintained and should be considered deprecated. The recommended remediation is to migrate to a maintained, drop-in replacement such as `pycryptodome`. First, uninstall the vulnerable library (`pip uninstall pycrypto`), then install the replacement (`pip install pycryptodome`). If immediate migration is not feasible, upgrading to pycrypto version 2.6.1 provides a patch for this specific vulnerability, but it does not address other issues in the unmaintained library and should only be considered a temporary mitigation.

How to confirm the fix worked

To validate the remediation, inspect the installed Python packages in all relevant application environments. Run `pip list` or `pip freeze` and verify that `pycrypto` is not present. Confirm that `pycryptodome` is installed as its replacement. Automated Software Composition Analysis (SCA) tools can be used to scan code repositories, build artifacts, and container images to detect any remaining instances of the vulnerable `pycrypto` package.

Typical attack path

  1. An attacker identifies a publicly accessible service using a vulnerable version of the pycrypto library.
  2. The attacker crafts a malicious request with an overly long initialization vector (IV) designed to trigger the buffer overflow.
  3. The attacker sends the request to the target application's cryptographic endpoint.
  4. The application's pycrypto library processes the IV, causing a heap overflow.
  5. The overflow corrupts memory, leading to arbitrary code execution on the server with the privileges of the application process.

How to detect it

Monitor application logs for unexpected crashes or segmentation faults, particularly in services that perform cryptographic functions. Analyze network traffic to these services for requests containing unusually long values in fields corresponding to initialization vectors (IVs). Look for anomalous process execution originating from the application process (e.g., a web server spawning a shell), which could indicate successful exploitation. If possible, analyze application crash dumps for evidence of heap corruption.

What your security team should do

  • Use Software Composition Analysis (SCA) tools to immediately identify all codebases, applications, and systems that use the `pycrypto` library.
  • Prioritize the migration from `pycrypto` to `pycryptodome` for all identified assets, focusing on internet-facing systems first.
  • If immediate migration is not possible, upgrade to the patched version 2.6.1 as a temporary measure and implement additional network-level monitoring and isolation for affected hosts.
  • Treat any application using older, unpatched versions of `pycrypto` as critically vulnerable and restrict its network access until it can be remediated.

The record

Heap-based buffer overflow in the ALGnew function in block_templace.c in Python Cryptography Toolkit (aka pycrypto) allows remote attackers to execute arbitrary code as demonstrated by a crafted iv parameter to cryptmsg.py.

Affected packages

Ecosystem Package Introduced Fixed
PyPI pycrypto 0 No fix
PyPI pycrypto 0 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4
Debian:7 python-crypto 0 2.6-4+deb7u4
Mageia:5 python-pycrypto 0 2.6.1-6.1.mga5
SUSE:Enterprise Storage 3 python-paramiko 0 1.15.2-2.3.1
SUSE:Enterprise Storage 3 python-pycrypto 0 2.6.1-10.3.1
SUSE:Enterprise Storage 4 python-pycrypto 0 2.6.1-10.3.1
SUSE:Linux Enterprise Module for Advanced Systems Management 12 python-pycrypto 0 2.6.1-10.3.1
SUSE:Linux Enterprise Module for Public Cloud 12 python-paramiko 0 1.15.2-2.6.1
SUSE:Linux Enterprise Module for Public Cloud 12 python-pycrypto 0 2.6.1-10.3.1
SUSE:Linux Enterprise Module for Web and Scripting 12 python-pycrypto 0 2.6.1-10.3.1
SUSE:Linux Enterprise Point of Sale 12 SP2 python-pycrypto 0 2.6.1-10.3.1
SUSE:Linux Enterprise Server 11 SP3-CLIENT-TOOLS python-pycrypto 0 2.6.1-5.1
SUSE:Linux Enterprise Server 11 SP4-CLIENT-TOOLS python-pycrypto 0 2.6.1-5.1
SUSE:Manager Client Tools 12 python-pycrypto 0 2.6.1-10.3.1
SUSE:Manager Proxy 3.0 python-pycrypto 0 2.6.1-10.3.1
SUSE:Manager Proxy 3.1 python-pycrypto 0 2.6.1-10.3.1
SUSE:Manager Server 3.0 python-pycrypto 0 2.6.1-10.3.1
SUSE:Manager Server 3.1 python-pycrypto 0 2.6.1-10.3.1
SUSE:Manager Tools 12 python-pycrypto 0 2.6.1-10.3.1
SUSE:OpenStack Cloud 6 python-paramiko 0 1.15.2-2.3.1
SUSE:OpenStack Cloud 6 python-pycrypto 0 2.6.1-10.3.1
SUSE:OpenStack Cloud 7 python-pycrypto 0 2.6.1-10.3.1
Ubuntu:14.04:LTS python-crypto 0 2.6.1-4ubuntu0.1
Ubuntu:14.04:LTS python-crypto 0 2.6.1-4ubuntu0.2
Ubuntu:16.04:LTS python-crypto 0 2.6.1-6ubuntu0.16.04.1
Ubuntu:16.04:LTS python-crypto 0 2.6.1-6ubuntu0.16.04.2

Related vulnerabilities