HyperSpy arbitrary code execution in stored model restoration
- Exploited
- No known exploitation
- Fix
- Fixed in 2.6.0
- Who is exposed
- Specific setups only
Summary
HyperSpy, a software package, can execute arbitrary Python code when a user restores a model from a crafted .hspy or .zspy file that contains a malicious pickle payload. The attacker must get the victim to open that file locally, and the attack needs no login.
Written by a model
Original description
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.
Who should check
Teams running HyperSpy 2.0.0-2.5.0 or 1.4.0-1.7.6 that restore stored models or build models from untrusted dictionaries or files.
Not fixed by: Setting trusted=True is not a fix; it permits Python deserialization and is not a sandbox.
“HyperSpy 2.x: >=2.0.0, <=2.5.0”
What to do
Check whether your setup matches what the bug needs.
Victim restores a crafted stored model or constructs a model from an untrusted dictionary (not ordinary hs.load() alone). HyperSpy 2.x versions from 2.0.0 through 2.5.0. HyperSpy 1.x releases (1.4.0 down to the affected range, dill-based sinks). The payload sits in a component's _class_dump data or a whitelist entry flagged fn in the stored model.Upgrade to a fixed version: 2.6.0.
Check your systems with an agent
Paste this into a coding or ops agent. It checks your systems read-only and reports a table per asset.
Check whether my systems are affected by CVE-2026-138118 (HyperSpy 1.4.0 before 2.6.0 Insecure Deserialization RCE via Stored Model Restoration), using the cve.now data below.
Rules: work read-only. Do not run exploit code, proof-of-concept scripts or scanners that send attack payloads, and do not change any configuration, package, image or deployment. Report findings only.
What cve.now has for CVE-2026-138118 (entry last updated 2026-11-28):
Affected:
- PyPI package hyperspy: from 1.4.0, fixed in 2.6.0
Fixed versions: 2.6.0.
Conditions (all must be true for the bug to be hit):
- Victim restores a crafted stored model or constructs a model from an untrusted dictionary (not ordinary hs.load() alone). (source: https://github.com/hyperspy/hyperspy/security/advisories/GHSA-j975-x368-3hrr)
- HyperSpy 2.x versions from 2.0.0 through 2.5.0. (source: https://github.com/hyperspy/hyperspy/security/advisories/GHSA-j975-x368-3hrr)
- HyperSpy 1.x releases (1.4.0 down to the affected range, dill-based sinks). (source: https://github.com/hyperspy/hyperspy/security/advisories/GHSA-j975-x368-3hrr)
- The payload sits in a component's _class_dump data or a whitelist entry flagged fn in the stored model. (source: https://github.com/hyperspy/hyperspy/security/advisories/GHSA-j975-x368-3hrr)
Setup: unknown whether the bug needs a non-default feature or setting. Check the advisory.
Attacker needs: local access, no login, a user action.
CISA KEV: CVE-2026-138118 is not listed as of cve.now's last read.
This KEV status is for CVE-2026-138118 only. If you also check another CVE, look up its own KEV status; never assume it from this one.
How to check:
- Packages (PyPI): find every lockfile in each project and run the stack.check operation of the cve.now MCP server (execute) on each one. Compare the resolved versions, not the ranges a manifest declares, with the affected versions above. Include transitive dependencies.
Verify against the linked advisories before concluding, and cite the date you read each one:
- https://github.com/hyperspy/hyperspy/security/advisories/GHSA-j975-x368-3hrr
- https://github.com/hyperspy/hyperspy/commit/6382ae0ff5b0000a7aad5dc2f4b997b1d8dccb09
- https://github.com/hyperspy/hyperspy/commit/28fdf2d0320c76c5d57a57e323ac510b2005e13d
- https://github.com/hyperspy/hyperspy/issues/3699
- https://github.com/hyperspy/hyperspy/releases/tag/v2.6.0
- https://github.com/hyperspy/hyperspy/blob/v2.5.0/hyperspy/model.py#L106-L146
- https://github.com/hyperspy/hyperspy/blob/v2.5.0/hyperspy/model.py#L645-L661
- https://github.com/hyperspy/hyperspy/blob/v2.5.0/hyperspy/misc/export_dictionary.py#L187-L207
Do not conclude an asset is unaffected unless you checked it and the evidence covers both its version and the conditions above. If you could not check something, mark it unknown and say what is missing.
Report a table with one row per asset and these columns: Asset | Version or build | Status (affected, fixed, not applicable, unknown) | Compensating controls | Exposure (internet-facing, internal, none) | Evidence | Next action.
Entry: https://cve.now/CVE-2026-138118
For follow-up questions, use the cve.now MCP server at https://mcp.cve.now/mcp (no authentication), for example execute with name cve.get and arguments {"id": "CVE-2026-138118"}.Affected versions
cve.now Index
- Exploitation?/40Unknown. No CISA SSVC exploitation rating yet
- Exposure5/25Specific setups only
- Reach10/20Affects PyPI packages
- Severity8.5/10CVSS 8.5
- No patch0/5No signal
What would change the score
- Would score about 74 if added to CISA KEV
- Would score about 69 if CISA's SSVC rates exploitation active
- Would score about 34 if CISA's SSVC rates it automatable
Timeline
- CVE published
- First seen by cve.now
Evidence 11
| Kind | Source |
|---|---|
| Vendor advisory 1Establishes: Affected and fixed versions. | |
| Advisory | GitHub · hyperspy/hyperspy · Advisory GHSA-j975-x368-3hrr |
| CVE record 2Establishes: The identifier and description. | |
| Record | CVE List · CVE-2026-138118 |
| Record | NVD · CVE-2026-138118 |
| Other links 8 | |
| Patch | GitHub · hyperspy/hyperspy · Commit 6382ae0f |
| Patch | GitHub · hyperspy/hyperspy · Commit 28fdf2d0 |
| Report | GitHub · hyperspy/hyperspy · Issue #3699 |
| Repository | GitHub · hyperspy/hyperspy · Release v2.6.0 |
| Repository | GitHub · hyperspy/hyperspy · hyperspy/model.py · L106-L146 |
| Repository | GitHub · hyperspy/hyperspy · hyperspy/model.py · L645-L661 |
| Repository | GitHub · hyperspy/hyperspy · hyperspy/misc/export_dictionary.py · L187-L207 |
| Link | vulncheck.com · advisories/hyperspy-1.4.0-before-2.6.0-insecure-deserialization-rce-via-stored-model-restoration |
Questions about CVE-2026-138118
Is CVE-2026-138118 being exploited?
It is not in CISA's Known Exploited Vulnerabilities catalog, and CISA's SSVC assessment does not mark exploitation as active. That does not mean it has not been attacked: vendors and researchers can report attacks before CISA lists them. No public exploit code is tracked.
Source: cve.now feed data
What does this mean?
Loading a crafted stored HyperSpy model, or building a model from an untrusted dictionary, can run arbitrary Python code with the privileges of the user doing the restore. The flaw is insecure deserialization of data stored inside the model.
Source: github.com
Which versions are affected by CVE-2026-138118?
hyperspy (PyPI): from 1.4.0 before 2.6.0.
Source: cve.now feed data
Am I affected, and how do I check?
The facts list HyperSpy 1.4.0 through the first fixed release, and HyperSpy 2.0.0 through 2.5.0 as affected; the 1.x series is end-of-life and gets no backport. To check a setup, run python -c "import hyperspy; print(hyperspy.__version__)" and compare the result with those ranges. The bug only applies when a stored model is restored or a model is built from an untrusted dictionary, not from ordinary hs.load() alone.
Source: github.com
How do I fix CVE-2026-138118?
No fixed version is named in the checked facts, so no upgrade target can be confirmed from them. Check the HyperSpy project's advisory for the fixed release and any vendor patch identifiers before deciding on an upgrade.
Source: github.com
Related
- CVE-2026-138117HyperSpy before 2.6.0 Code Execution via sympy.sympify() in HSPY/ZSPY Files
- CVE-2026-134994WordPress Revertix – Backup, Migration, Staging & Clone plugin <= 1.0.3 - PHP Object Injection vulnerability
- CVE-2026-131767WordPress FunnelKit Automations plugin <= 3.9.0.1 - PHP Object Injection vulnerability
- CVE-2026-134481WordPress Ultimate Member plugin <= 2.14.1 - PHP Object Injection vulnerability
- CVE-2026-106169Unsafe Java Deserialization in Application Integration allows Remote Code Execution
- CVE-2026-77230Camunda 8 Insecure Deserialization via Web Session Storage
No corrections so far. Something wrong on this page? Report an error.