Document that an unimplemented opcode raises rather than being skipped (and 4 missing opcodes)
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
- 64/100
Direzione di ricerca
Inizia da Opcode.new e dalla tabella OPCODES_BY_NAME in fickling.fickle, quindi confronta la tabella con Python's pickletools.opcodes. Documenta che gli opcode non supportati sollevano NotImplementedError invece di essere ignorati e valuta l'aggiunta dei quattro opcode mancanti indicati. Il lavoro è completato quando la garanzia di sicurezza è documentata e qualsiasi modifica agli opcode è coperta dai controlli esistenti del progetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Fickling's opcode table is missing four opcodes that CPython's pickletools knows, and the safety of that gap rests entirely on an undocumented behaviour: Opcode.__new__ raises on an unimplemented opcode rather than skipping it. That failure mode is load-bearing for downstream tools, and I would like to see it stated as a guarantee.
This is not a vulnerability report — the current behaviour is safe. It is a request to document what makes it safe, plus four opcodes you may want to add.
The gap
>>> import pickletools
>>> from fickling.fickle import OPCODES_BY_NAME
>>> sorted({op.name for op in pickletools.opcodes} - set(OPCODES_BY_NAME))
['BYTEARRAY8', 'FLOAT', 'NEXT_BUFFER', 'READONLY_BUFFER']
68 opcodes in CPython, 64 in fickling. FLOAT is protocol 0, not an exotic protocol-5 addition.
Why it matters, and why it is currently fine
A pickle can be made whose prefix fickling cannot decode but CPython walks straight through:
>>> import io, pickletools
>>> data = b"}" + b"F1.0\n" + b"cos\nsystem\n(S'echo pwned'\ntR."
>>> [op.name for op, _, _ in pickletools.genops(io.BytesIO(data))]
['EMPTY_DICT', 'FLOAT', 'GLOBAL', 'MARK', 'STRING', 'TUPLE', 'REDUCE', 'STOP']
CPython reaches GLOBAL and REDUCE. Fickling cannot get past FLOAT.
That is not exploitable today, because the dispatch in Opcode.__new__ raises instead of continuing:
raise NotImplementedError(f"TODO: Add support for Opcode {info.name}")
The file therefore surfaces as an error, and a caller that treats errors as unsafe is protected. The important detail is that this is a single central dispatch, so it holds uniformly for all four and for any future unknown opcode — the safe behaviour is a property of the architecture, not an accident of these particular opcodes.
The request
Document that an unimplemented opcode raises rather than being skipped, as a guarantee rather than an implementation detail.
Downstream tools depend on it whether they realise it or not. Ours does: we treat "fickling could not parse this" as "do not report this file as clean". If the dispatch were ever relaxed to skip unknown opcodes — a plausible, well-intentioned robustness change — every such tool would silently start reporting these files as safe, and nothing in the current documentation says that would be a breaking change.
Adding the four opcodes is worth doing and is additive. But it narrows this particular gap rather than closing the class: the table can drift from CPython again at the next protocol addition, and the loud failure is what makes that drift safe.
A note on your reporting guidelines
SECURITY.md asks for reproductions via the opcode API rather than raw byte strings, and I have followed that elsewhere. It is not possible here by construction: the finding is precisely that FLOAT, BYTEARRAY8, NEXT_BUFFER and READONLY_BUFFER have no representation in the opcode API, because they are not implemented. Raw bytes are the only way to express a pickle containing them — which is itself a small argument for adding them.
I have used echo in the proof of concept, per the same guidance.
Versions
master at 854c99a; also reproduced on the 0.1.12 release.
- 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
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
trailofbits/fickling#346 ·
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
-
bug game: 0100FF500E34A000 game: 0400FF500E34A001 mac packing
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
jxxghp/MoviePilot#7576 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
jbaruch/software-factory#266 ·
I maintainer di solito rispondono entro 1 giorno
-
cron: raise a distinct error when next_fire finds no match in its search bound (from #813 item 5)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno