CVE-2024-23346

9.3 CRITICAL

📋 TL;DR

CVE-2024-23346 is a critical remote code execution vulnerability in Pymatgen's JonesFaithfulTransformation.from_transformation_str() method that uses eval() on untrusted input. This allows attackers to execute arbitrary Python code when processing malicious input strings. All users of Pymatgen versions before 2024.2.20 are affected.

💻 Affected Systems

Products:
  • Pymatgen (Python Materials Genomics)
Versions: All versions before 2024.2.20
Operating Systems: All operating systems running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists in default configuration when using the affected method with untrusted input.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with attacker gaining complete control over the server, data exfiltration, lateral movement, and persistence establishment.

🟠

Likely Case

Arbitrary code execution in the context of the Pymatgen application, potentially leading to data theft, system manipulation, or further exploitation.

🟢

If Mitigated

Limited impact if input validation and sanitization are implemented, restricting exploitation to specific contexts.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires the vulnerable method to be called with attacker-controlled input.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2024.2.20

Vendor Advisory: https://github.com/materialsproject/pymatgen/security/advisories/GHSA-vgv8-5cpj-qj2f

Restart Required: No

Instructions:

1. Update Pymatgen using pip: pip install --upgrade pymatgen==2024.2.20
2. Verify the update completed successfully
3. Test application functionality to ensure compatibility

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation to only allow expected transformation strings and reject any input containing potentially dangerous characters.

Method Restriction

all

Disable or restrict access to the JonesFaithfulTransformation.from_transformation_str() method if not required for functionality.

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all inputs to the vulnerable method
  • Isolate the vulnerable application in a restricted network segment with minimal privileges

🔍 How to Verify

Check if Vulnerable:

Check if Pymatgen version is below 2024.2.20 and if the application uses JonesFaithfulTransformation.from_transformation_str() method with user input.

Check Version:

python -c "import pymatgen; print(pymatgen.__version__)"

Verify Fix Applied:

Verify Pymatgen version is 2024.2.20 or higher and test that the method no longer accepts malicious input.

📡 Detection & Monitoring

Log Indicators:

  • Unusual Python execution errors
  • Suspicious import statements in transformation strings
  • Unexpected system commands in application logs

Network Indicators:

  • Unusual outbound connections from Pymatgen application
  • Data exfiltration patterns

SIEM Query:

source="application.logs" AND ("JonesFaithfulTransformation" OR "from_transformation_str") AND ("eval" OR "import" OR "os.system" OR "subprocess")

🔗 References

📤 Share & Export