Skip to content

gh-145986: Avoid unbound C recursion in conv_content_model in pyexpat.c (CVE 2026-4224) - #145987

Merged
picnixz merged 7 commits into
python:mainfrom
StanFromIreland:expat-crash
Mar 15, 2026
Merged

picnixz merged 7 commits into
python:mainfrom
StanFromIreland:expat-crash

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Mar 15, 2026 •

Copy link
Copy Markdown
Member
Comment thread Lib/test/test_pyexpat.py Resolved
Comment thread Lib/test/test_pyexpat.py Resolved
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@StanFromIreland
StanFromIreland requested a review from picnixz March 15, 2026 19:43
Comment thread Lib/test/test_pyexpat.py Resolved
@picnixz picnixz changed the title gh-145986: Avoid unbound C recursion in conv_content_model in pyexpat.c Mar 15, 2026
@picnixz
picnixz merged commit eb0e8be into python:main Mar 15, 2026
51 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11, 3.12, 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 15, 2026
… `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 15, 2026
… `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 15, 2026

Copy link
Copy Markdown

GH-145995 is a backport of this pull request to the 3.14 branch.

@miss-islington-app

Copy link
Copy Markdown

Sorry, @StanFromIreland and @picnixz, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker eb0e8be3a7e11b87d198a2c3af1ed0eccf532768 3.12
@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Mar 15, 2026
@bedevere-app

bedevere-app Bot commented Mar 15, 2026

Copy link
Copy Markdown

GH-145996 is a backport of this pull request to the 3.13 branch.

@miss-islington-app

Copy link
Copy Markdown

Sorry, @StanFromIreland and @picnixz, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker eb0e8be3a7e11b87d198a2c3af1ed0eccf532768 3.11
@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Mar 15, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @StanFromIreland and @picnixz, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker eb0e8be3a7e11b87d198a2c3af1ed0eccf532768 3.10
@StanFromIreland
StanFromIreland deleted the expat-crash branch March 15, 2026 21:48
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Mar 15, 2026
…del` in `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Mar 15, 2026
…del` in `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 15, 2026

Copy link
Copy Markdown

GH-145999 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 15, 2026
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Mar 15, 2026
…del` in `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)
(cherry picked from commit e5caf45)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 15, 2026

Copy link
Copy Markdown

GH-146000 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Mar 15, 2026
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Mar 15, 2026
…del` in `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)
(cherry picked from commit e5caf45)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 15, 2026

Copy link
Copy Markdown

GH-146002 is a backport of this pull request to the 3.10 branch.

picnixz added a commit that referenced this pull request Mar 15, 2026
…n `pyexpat.c` (CVE 2026-4224) (GH-145987) (#145995)

gh-145986: Avoid unbound C recursion in `conv_content_model` in `pyexpat.c` (CVE 2026-4224) (GH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
kumaraditya303 pushed a commit that referenced this pull request Mar 16, 2026
…n `pyexpat.c` (CVE 2026-4224) (GH-145987) (#145996)

* gh-145986: Avoid unbound C recursion in `conv_content_model` in `pyexpat.c` (CVE 2026-4224) (GH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Remvoe `skip_if_unlimited_stack_size` decorator

* Remove more decorators not on this branch

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@nikhilgv

Copy link
Copy Markdown

Hello @StanFromIreland , will this be backported to python 3.9?

@StanFromIreland

Copy link
Copy Markdown
Member Author

No, 3.9 is EOL.

pablogsal pushed a commit that referenced this pull request Apr 8, 2026
…n `pyexpat.c` (CVE 2026-4224) (GH-145987) (#146000)

* [3.11] gh-145986: Avoid unbound C recursion in `conv_content_model` in `pyexpat.c` (CVE 2026-4224) (GH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)
(cherry picked from commit e5caf45)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Update Misc/NEWS.d/next/Security/2026-03-14-17-31-39.gh-issue-145986.ifSSr8.rst

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
pablogsal pushed a commit that referenced this pull request Apr 8, 2026
…n `pyexpat.c` (CVE 2026-4224) (GH-145987) (#146002)

* [3.10] gh-145986: Avoid unbound C recursion in `conv_content_model` in `pyexpat.c` (CVE 2026-4224) (GH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)
(cherry picked from commit e5caf45)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Update Misc/NEWS.d/next/Security/2026-03-14-17-31-39.gh-issue-145986.ifSSr8.rst

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
… `pyexpat.c` (CVE 2026-4224) (python#145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Yhg1s pushed a commit that referenced this pull request Aug 4, 2026
…n `pyexpat.c` (CVE 2026-4224) (GH-145987) (#145999)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

(cherry picked from commit eb0e8be)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
icanhasmath pushed a commit to ActiveState/cpython that referenced this pull request Oct 28, 2026
…del` in `pyexpat.c` (CVE 2026-4224) (pythonGH-145987) (python#146002)

* [3.10] pythongh-145986: Avoid unbound C recursion in `conv_content_model` in `pyexpat.c` (CVE 2026-4224) (pythonGH-145987)

Fix C stack overflow (CVE-2026-4224) when an Expat parser
with a registered `ElementDeclHandler` parses inline DTD
containing deeply nested content model.

---------
(cherry picked from commit eb0e8be)
(cherry picked from commit e5caf45)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Update Misc/NEWS.d/next/Security/2026-03-14-17-31-39.gh-issue-145986.ifSSr8.rst

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
(cherry picked from commit af856a7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants