VAITP Dataset

← Back to the dataset

CVE-2024-23346

Critical vulnerability in Pymatgen allows arbitrary code execution via eval().

  • CVSS 7.8
  • CWE-77
  • Input Validation and Sanitization
  • Remote

Pymatgen (Python Materials Genomics) is an open-source Python library for materials analysis. A critical security vulnerability exists in the `JonesFaithfulTransformation.from_transformation_str()` method within the `pymatgen` library prior to version 2024.2.20. This method insecurely utilizes `eval()` for processing input, enabling execution of arbitrary code when parsing untrusted input. Version 2024.2.20 fixes this issue.

CVSS base score
7.8
Published
2024-02-21
OWASP
A01 Injection
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Pymatgen
Fixed by upgrading
Yes

Solution

Upgrade to Pymatgen version 2024.2.20 or later.

Vulnerable code sample

from pymatgen.transformations.standard_transformations import JonesFaithfulTransformation

# Example of insecure usage that could lead to code execution
transformation_str = "__import__('os').system('echo Vulnerable!')"
transformation = JonesFaithfulTransformation.from_transformation_str(transformation_str)

Patched code sample

from pymatgen.transformations.standard_transformations import JonesFaithfulTransformation

# Example of secure usage without eval
transformation_str = "some_safe_transformation_string"
transformation = JonesFaithfulTransformation.from_transformation_str(transformation_str)

Payload

"__import__('os').system('ls')"

Cite this entry

@misc{vaitp:cve202423346,
  title        = {{Critical vulnerability in Pymatgen allows arbitrary code execution via eval().}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2024-23346},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-23346/}}
}
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 ::