is_likely_safe() only checks the first pickle stream in a file
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 30/100
Direzione di ricerca
Start at is_likely_safe() in fickling/analysis.py (around lines 686-692), which calls Pickled.load(..., fail_on_decode_error=False) and so reads only the first stream. Compare with how fickling/cli.py:312 and fickling/loader.py:246 use StackedPickle.load(). Run the reproducer in the issue, which writes a stacked file and calls is_likely_safe(), and confirm it returns False once every stream is checked. Done means is_likely_safe() agrees with the CLI on stacked and legacy PyTorch files. A fix PR is reportedly under way but is not linked, and the report is under embargo, so check with maintainers before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
fickling.is_likely_safe(filepath) (fickling/analysis.py:686-692) reads the file with Pickled.load(f, fail_on_decode_error=False), which stops at the first STOP opcode. Later pickle streams in the same file are not decoded or passed to check_safety(), so the result depends on the first stream only. The CLI safety check (fickling/cli.py:312) and fickling.loader (fickling/loader.py:246) read the whole file with StackedPickle.load(), so they can disagree with is_likely_safe() on the same file.
Reproducer with the stdlib pickle module and the opcode API (nothing is unpickled):
import pickle
import tempfile
from pathlib import Path
import fickling
import fickling.fickle as op
from fickling.analysis import check_safety
from fickling.fickle import Pickled
second = Pickled(
[
op.Proto.create(4),
op.ShortBinUnicode("os"),
op.ShortBinUnicode("system"),
op.StackGlobal(),
op.Stop(),
]
)
print(check_safety(second).severity) # LIKELY_OVERTLY_MALICIOUS on its own
with tempfile.TemporaryDirectory() as d:
path = Path(d) / "stacked.pkl"
path.write_bytes(pickle.dumps({"label": 1}) + second.dumps())
print(fickling.is_likely_safe(str(path))) # True on master
The same applies to PyTorch files in the legacy non-zip format, which hold five pickle streams where the first is only the magic number: is_likely_safe() returns True for them whatever the object stream contains, while fickling --check-safety on the same file exits 1.
Reported privately as GHSA-vv58-2pw5-4fcf and opened here at the maintainers' request. A fix is in a pull request that switches is_likely_safe() to StackedPickle.load() and requires every stream to be rated LIKELY_SAFE.
- Lingua principale
- Python
- Stelle
- 678
- Fork
- 89
- Merge medio
- 41m
- PR unite (30g)
- 14
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di trailofbits/fickling
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
trailofbits/fickling#355 ·
I maintainer di solito rispondono entro 1 giorno
-
Document that an unimplemented opcode raises rather than being skipped (and 4 missing opcodes)Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
trailofbits/fickling#322 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
stdlib check depends on the scanner's Python versionForse già presa @thomas-chauchefoin-tob l’ha presa 117 giorni fa. Aperta
trailofbits/fickling#311 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Further align the CLI and Python APIForse già presa @dguido l’ha presa 306 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
trailofbits/fickling#101 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
trailofbits/fickling#97 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di trailofbits/fickling
Issue simili
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shardsApertastatus/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
microsoft/apm#5309 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug vector-store
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
EverMind-AI/Raven#1413 ·
I maintainer di solito rispondono entro 1 giorno
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
I maintainer di solito rispondono entro 2 giorni