Skip to content
github.com https://github.com/gammapy/gammapy/issues/7086 Code

github.com https://github.com/gammapy/gammapy/issues/7086 Code

github.com • November 22, 2026

Loading an attacker-supplied .fits or .fits.gz map with gammapy.maps.Map.read runs arbitrary code as the user. A geometry shape is stored in the map header as the WCSSHAPE card, and on read gammapy evaluates it with eval() . Local file, one read, full code execution.

In gammapy/maps/wcs/geom.py , WcsGeom.from_header (reached by Map.read ) rebuilds the geometry from the FITS header and does:

eval is called with no globals argument, so it runs in the module namespace with the real builtins, and header["WCSSHAPE"] is read verbatim from the file. to_header writes header["WCSSHAPE"] = f"({shape})" , so every saved WcsGeom carries the card and it round-trips; the attacker only edits one header card. The same code is present on the default branch HEAD.

Save a map, then change its WCSSHAPE card with astropy.io.fits from a numeric tuple such as (10, 10) to a Python expression, for example set WCSSHAPE to __import__('os').system('id > /tmp/gammapy_poc') . Then:

id runs during the read. The control (the unmodified map, WCSSHAPE a numeric tuple) runs nothing. Confirmed on gammapy 2.1 with astropy, Python 3 on Linux.

Any gammapy user who opens a .fits map received from a collaborator, a repository, or a paper's supplementary data runs that file's code with their privileges, typically on an analysis workstation, an HPC node, or a CI runner. Nothing in the loaded map reveals it.

Do not eval the WCSSHAPE card. Parse it with ast.literal_eval (the card is always a numeric tuple), or store and read the shape as explicit integer header keywords.

Affected versions: <= 2.1 (and main HEAD)

Severity: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H (7.8)

Weaknesses: CWE-95, CWE-94

Dilanka Kaushal Hewage (r3vpwnx)

registerrier self-assigned this on Nov 21, 2026

registerrier added this to the 2.2 milestone on Nov 21, 2026

registerrier closed this as completed on Nov 21, 2026

The full story

This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.

Extracted Entities

Attack Types (1)

CWE Weaknesses (1)

Domains (1)

Platforms (1)