Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

pyexpat: CPython can be crashed through resetting `StartDoctypeDeclHandler` with pyexpat at the wrong time

Aperta
#160,442 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, xml
Ambito
backend, security

Direzione di ricerca

The report provides a reproducer using xml.parsers.expat.ParserCreate and says Expat upstream pull request #1437 fixes the crash. Start by checking how CPython vendors or updates Expat and whether that upstream fix is already included. Done means the reproducer no longer crashes; the report says this is defense-in-depth, not a vulnerability.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

extension-modules topic-XML type-crash

Hello!

It has been brought to my attention that the Expat XML parser can be crashed via a segmentation fault by resetting member StartDoctypeDeclHandler at the wrong time, like this:

from xml.parsers.expat import ParserCreate

parser = ParserCreate()

def reset_start_doctype_handler():
    parser.StartDoctypeDeclHandler = None
    return True

parser.StartDoctypeDeclHandler = lambda *_: None
parser.NotStandaloneHandler = reset_start_doctype_handler

parser.Parse(b"<!DOCTYPE r SYSTEM \"s\"><r/>", True)

This affects all versions of Python with all versions of Expat up to 2.9.0 including. Expat upstream pull request https://github.com/libexpat/libexpat/pull/1437 fixes this issue for itself and CPython and the fix will be contained in the next release that may come out as early as next Monday. So updating to the next release will fix this for Python for free, I just wanted to let you know.

Credits for this finding go to Bartłomiej Dmitruk (@hackerman70000) of https://www.striga.ai/ .

Bartłomiej reported this as defense-in-depth to me and we both do not consider this a vulnerability. If you come to difference conclusions, please let me know.

Best, Sebastian

CC @StanFromIreland @picnixz

Lingua principale
Python
Stelle
77.8k
Fork
37.7k
Merge medio
12h 27m
PR unite (30g)
710

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python/cpython

Tutte le issue di python/cpython

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.