/

CVE-2026-134694

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-95) in Gammapy WcsGeom.from_header

CVE-2026-134694

Received

Vulnerability type

Category:

Code Injection

CWE:

CWE-95

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Gammapy evaluates the WCSSHAPE FITS header value in WcsGeom.from_header(), which can allow a crafted FITS file to execute Python code. The risk arises when a user loads a file containing a malicious header through Map.read(), causing the code to run with that user's permissions.

Affected context

The issue occurs in Gammapy's FITS file handling when WcsGeom.from_header() processes the WCSSHAPE header card using eval(). It may affect workflows that load FITS files through Map.read() when an attacker can influence the file being opened.

Exploit preconditions

  • Attack surface: FITS file ingestion through Gammapy's map-reading functionality
  • Required access: Ability to provide or influence a FITS file that a user will load
  • Trigger point: Processing of the WCSSHAPE header by WcsGeom.from_header() during Map.read()
  • Why exploitation is possible: Header content is evaluated as Python code rather than handled strictly as data

Why this happens

The underlying bug is the use of eval() on a value taken from a FITS header. Because the header can be influenced through the input file, treating its contents as executable Python creates a code-injection weakness. This maps to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code.

Potential impact

  • Arbitrary code could run with the permissions of the user loading the file.
  • An attacker may be able to access or modify data available to that user.
  • The affected process or environment could be compromised.
  • Malicious code could disrupt analysis workflows or access local resources.

General mitigation guidance

Defensive patterns focus on preventing file metadata from being interpreted as code:

  • Replace dynamic evaluation with explicit parsing of the expected header format.
  • Validate parsed values against a strict schema, including type, range, and structure checks.
  • Treat externally supplied FITS files and their metadata as untrusted.
  • Load and process files in isolated environments with least-privilege permissions.
  • Apply resource and filesystem restrictions to limit the impact of unexpected input.

How teams detect issues like this

  • Use static analysis to identify eval() and similar dynamic execution functions applied to file contents or metadata.
  • Review parsing code for paths that pass FITS header values into interpreters or general-purpose expression evaluators.
  • Add automated checks that reject unsafe evaluation patterns in code review and build policies.
  • Test file parsers with malformed and unexpected metadata, verifying that inputs are treated only as data.

Sources

SourceLink
github.comgithub.com/gammapy/gammapy/blob/v2.1/gammapy/maps/wcs/geom.py
github.comgithub.com/gammapy/gammapy/commit/1be273b648e814c0605d8f3610d056c9c62130ca
github.comgithub.com/gammapy/gammapy/issues/7086
vulncheck.comvulncheck.com/advisories/gammapy-through-2.1-code-injection-via-wcsshape-fits-header-card

Frequently asked

questions

The described trigger is loading a crafted FITS file. It may be delivered remotely, but code execution occurs when a user or process loads that file.

An attacker needs a way to provide or influence a FITS file that will be processed. The code runs with the permissions of the process loading it.

Avoid evaluating header values as code. Parse the expected data format explicitly and validate the result against strict constraints.

Treat file metadata as untrusted input, use non-executable parsers, and apply static analysis and code review checks for dynamic evaluation of external data.

Find out what's already
exploitable in your codebase.