CVE-2026-138118 in HyperSpy
Summary
by MITRE • 11/28/2026
HyperSpy from 1.4.0 before 2.6.0 contains an insecure deserialization vulnerability that allows attackers to execute arbitrary Python code by supplying crafted stored-model data in .hspy or .zspy files. Attackers can embed a malicious pickle payload in a component's _class_dump or a 'fn'-flagged _whitelist entry, which cloudpickle.loads() (dill in 1.x) runs when the victim restores the model.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 11/28/2026
HyperSpy versions ranging from 1.4.0 up to but not including version 2.6.0 are susceptible to a critical insecure deserialization vulnerability that poses significant risks to data integrity and system security. This flaw stems from the application's handling of stored-model files, specifically those with .hspy or .zspy extensions, which utilize Python pickle serialization formats for persisting complex object states. When an analyst opens such a file within HyperSpy, the software attempts to reconstruct the original objects by deserializing the embedded data structures. The vulnerability arises because the deserialization process does not adequately restrict the types of objects that can be instantiated or executed during this reconstruction phase, allowing maliciously crafted payloads to trigger arbitrary code execution upon loading.
The technical mechanism behind this exploitation involves the manipulation of specific internal attributes within the serialized model files. Attackers can embed a malicious pickle payload directly into a component's class_dump attribute or exploit entries flagged with 'fn' in the _whitelist structure. When the victim restores the model, HyperSpy invokes cloudpickle.loads() for versions prior to 2.x and dill.loads() for version 1.x series to process these attributes. Both libraries are designed to handle complex Python object serialization but inherently support arbitrary code execution during deserialization if not properly sandboxed or restricted. By crafting a file where the _class_dump contains an exploit payload, such as one that instantiates a class with a __reduce_ method returning system commands, the attacker ensures that when cloudpickle.loads() processes this data, it executes the embedded malicious logic rather than simply reconstructing benign scientific data structures.
The operational impact of this vulnerability is severe, granting remote attackers or those with access to shared files the ability to execute arbitrary Python code on the victim's machine under the context of the user running HyperSpy. This can lead to a complete compromise of the workstation, including theft of sensitive research data, installation of malware, pivoting into internal networks if the system is connected, and modification of scientific results for malicious purposes. Since .hspy files are commonly shared among researchers in fields like electron microscopy and spectroscopy, this vulnerability presents a high-risk vector for supply chain attacks or targeted phishing campaigns where victims are tricked into opening seemingly legitimate data files from untrusted sources. The lack of input validation on the deserialization targets means that any file containing such crafted payloads will trigger execution without warning to the user.
To mitigate these risks, organizations and individual researchers should immediately upgrade HyperSpy to version 2.6.0 or later, where this insecure deserialization path has been addressed through stricter serialization controls and safer handling of model data. For environments unable to update immediately, it is crucial to enforce strict file intake policies that prevent the opening of .hspy or .zspy files from untrusted sources without prior inspection using static analysis tools capable of detecting malicious pickle payloads. Additionally, running HyperSpy within a restricted sandboxed environment with limited filesystem and network access can reduce the blast radius if an exploit is inadvertently triggered. Security teams should also monitor for unusual process executions originating from Python interpreters when scientific data files are accessed, as this may indicate active exploitation attempts aligned with techniques described in CWE-502 regarding deserialization of untrusted data and MITRE ATT&CK technique T1648 related to supply chain compromise via malicious artifacts.