Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#160,442 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python, xml
Bereich
backend, security

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Python
Sterne
77.7k
Forks
38.3k
Ø Merge
13 Std. 43 Min.
Gemergte PRs (30 T.)
704

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python/cpython

Alle Issues in python/cpython

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.