GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.14] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) by picnixz · Pull Request #139359 · python/cpython

Conversation

@picnixz

@picnixz picnixz commented Sep 26, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Expose the XML Expat 2.7.2 mitigation APIs to disallow use of disproportional amounts of dynamic memory from within an Expat parser (see CVE-2025-59375 for instance).

The exposed APIs are available on Expat parsers, that is, parsers created by xml.parsers.expat.ParserCreate(), as:

  • parser.SetAllocTrackerActivationThreshold(threshold), and
  • parser.SetAllocTrackerMaximumAmplification(max_factor).

(cherry picked from commits f04bea4 and 68a1778)

  • Issue: Expose Expat XML attack protection APIs #90949

📚 Documentation preview 📚: https://cpython-previews--139359.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Sep 26, 2025
Expose Expat XML attack protection APIs #90949
Closed
gh-90949: add Expat API to prevent XML deadly allocations #139234
Merged
@bedevere-app bedevere-app Bot added the topic-XML label Sep 26, 2025
@picnixz
picnixz force-pushed the backport-f04bea4-3.14 branch from 2c87b60 to 1f60895 Compare September 26, 2025 14:43
@picnixz
picnixz marked this pull request as ready for review September 26, 2025 14:44
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 26, 2025
@picnixz
picnixz force-pushed the backport-f04bea4-3.14 branch from 1f60895 to f2030ab Compare September 26, 2025 15:15
@picnixz
[3.14] pythongh-90949: add Expat API to prevent XML deadly allocations (
3c430ec
CVE-2025-59375) (pythonGH-139234)

Expose the XML Expat 2.7.2 mitigation APIs to disallow use of
disproportional amounts of dynamic memory from within an Expat
parser (see CVE-2025-59375 for instance).

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetAllocTrackerActivationThreshold(threshold)`, and
- `parser.SetAllocTrackerMaximumAmplification(max_factor)`.

(cherry picked from commit f04bea4)

Co-authored-by: Bénédikt Tran <[email protected]>
@picnixz
picnixz force-pushed the backport-f04bea4-3.14 branch from f2030ab to 3c430ec Compare September 26, 2025 15:15
@picnixz

picnixz commented Sep 26, 2025

Copy link
Copy Markdown
Member Author

I'll wait until gh-139366 is merged to ease future backports

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
picnixz marked this pull request as draft September 26, 2025 16:23
@bedevere-app bedevere-app Bot removed the awaiting core review label Sep 26, 2025
@picnixz

This comment was marked as resolved.

Sign in to view
picnixz added 2 commits September 28, 2025 13:09
@picnixz
Merge branch '3.14' into backport-f04bea4-3.14
ced3c5d
@picnixz
pythongh-90949: amend pythonGH-139234 in prevision of future mitigati…
b52fc88
…on API (python#139366)

Fix some typos left in f04bea4,
and simplify some internal functions to ease maintenance of future
mitigation APIs.
@picnixz
picnixz marked this pull request as ready for review September 28, 2025 11:25
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 28, 2025
@hartwork

hartwork commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

I'll wait until gh-139366 is merged to ease future backports

@picnixz if I'm not mistaken, it's both merged and cherry-picked to this PR (as the third commit) by now. What would be the next steps for this pull request?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Sep 28, 2025

Copy link
Copy Markdown
Member Author

A core developer needs to review it, and the release manager needs to approve it because we're in RC3 phase. I really want at least two core devs to check this PR to be sure I didn't mess the backports. I didn't backport the docs changes that will be added in the next one (the one for billion laughs).

hartwork reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
picnixz requested a review from gpshead September 28, 2025 14:11
@hartwork

hartwork commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

@picnixz so the plan is to first get review from Gregory and only then Hugo, I see 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Sep 28, 2025

Copy link
Copy Markdown
Member Author

I would be happy if you could also review it as you're an expert here as well :')

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hartwork
hartwork approved these changes Sep 28, 2025
View reviewed changes

@hartwork hartwork left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be happy if you could also review it as you're an expert here as well :')

@picnixz done, looks good 👍

My method of review has been comparing (1) the diff of #139234 against main with (2) the diff in here. What I found was no difference but:

  • Doc/whatsnew/3.15.rst on main side but not 3.14 (as expected)
  • @permit_long_* on main side but not 3.14 (as expected)

The tools I used for this were git rebase -i, git diff and Meld.

So if #139234 was alright (which I believe) then very likely this is, too 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@picnixz

picnixz commented Sep 28, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Thank you for the review. I'll let Gregory have a look and then Hugo can hit merge I think (only he can merge during RC phase).

For the other branches, I would suggest you continue your branch for 3.13 with the latest stuff (or try to directly cherry-pick this specific PR with a new one). I think we should be able to backport this PR to 3.13 directly without too many conflicts (I hope).

hartwork reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hartwork hartwork mentioned this pull request Sep 28, 2025
[3.13] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) #139367
Merged
@gpshead

gpshead commented Sep 29, 2025

Copy link
Copy Markdown
Member

FWIW when to merge this is up to the release manager (hugovk). As we're treating it as a security mitigation feature similar to past such things and adding it to older releases as well, that suggests letting this wait for 3.14.1 is fine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead approved these changes Sep 29, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Sep 29, 2025
@picnixz

picnixz commented Sep 30, 2025

Copy link
Copy Markdown
Member Author

Note for the RM: we have a UAF in all branches, independently of Expat version: See #139400. So I would prefer that this one is not backported until we fix it. On 3.14 we don't see the crash, but on 3.13 (and probably on older branches), we will also see it. I believe we are able not to crash by chance due to some magic in incremental GC.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hartwork

hartwork commented Sep 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Note for the RM: we have a UAF in all branches, independently of Expat version: See #139400.

…and a WIP candidate fix at #139403.

On 3.14 we don't see the crash, but on 3.13 (and probably on older branches), we will also see it. I believe we are able not to crash by chance due to some magic in incremental GC.

@picnixz In my tests on another notebook I saw two other branches affected directly and once we add del parent_parser all branches are. I'm with you that changes in the garbage collector could take part in 3.14 and main behaving slightly differently.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
Merge branch '3.14' into backport-f04bea4-3.14
992018f
@picnixz

picnixz commented Oct 7, 2025

Copy link
Copy Markdown
Member Author

We will merge this one in 3.14.1 (3.14 is now ongoing its release process). To have a good synchronization, we'll also delay 3.10 to 3.13 backports for their next release cycle.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz self-assigned this Oct 7, 2025
This was referenced Oct 7, 2025
[3.12] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) #139527
Merged
[3.11] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) #139529
Merged
[3.10] gh-90949: add Expat API to prevent XML deadly allocations (CVE-2025-59375) (GH-139234) #139532
Merged
picnixz added 2 commits October 7, 2025 14:02
@picnixz
Merge branch '3.14' into backport-f04bea4-3.14
6fb5cd8
@picnixz
Merge branch '3.14' into backport-f04bea4-3.14
c13d940
@picnixz

picnixz commented Oct 26, 2025

Copy link
Copy Markdown
Member Author

I'm going to work on merging the deadly allocation PR now. Sorry for the delay but I got very busy with my new work & IRL

hartwork reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz added 2 commits October 26, 2025 11:54
@picnixz
fix docs
41b0aa2
@picnixz
Revert "fix docs"
52edaa7
This reverts commit 41b0aa2.
@picnixz

picnixz commented Oct 26, 2025

Copy link
Copy Markdown
Member Author

Ok, so here's the plan:

  • There are slight mistakes in the docs for this PR that were later corrected in gh-90949: expose Expat API to tune exponential expansion protections #139368.
  • I will keep those slight wording mistakes because it would complicate the backport of gh-90949: expose Expat API to tune exponential expansion protections #139368 otherwise...

@hartwork Can you check your existing PRs please? I think it'd be fine to actually merge the 3.10-3.14 ones and their backports as we have roughly 2 months until the next release.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hartwork

hartwork commented Oct 26, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I will keep those slight wording mistakes because it would complicate the backport

@picnixz yes please, a backport is not the place to fix up on the original as far as I am concerned.

@hartwork Can you check your existing PRs please?

I believe I got them all into mergable shape and they just need a re-trigger of CI — the read-the-docs one is flaky — to be green and ready. I am missing something? Anything in particular that you'd want me to check or re-check for?

I think it'd be fine to actually merge the 3.10-3.14 ones and their backports as we have roughly 2 months until the next release.

Cool!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hartwork

hartwork commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

I'm going to work on merging the deadly allocation PR now. Sorry for the delay but I got very busy with my new work & IRL

@picnixz thank you! 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hartwork

hartwork commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

@hartwork Can you check your existing PRs please?

@picnixz they all end in commit "Drop workaround for 139400 as no-longer-needed" and their commits tell the same story. I'm happy to fix anything that needs fixing, but I believe they're all ready and have been.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Nov 2, 2025

Copy link
Copy Markdown
Member Author

Perfect, I'm going to merge them all and then we'll move on to adding the other API (with the docs amendments)

hartwork reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz
Merge branch '3.14' into backport-f04bea4-3.14
0e60215
@picnixz
picnixz enabled auto-merge (squash) November 2, 2025 09:08
@picnixz
picnixz merged commit bf2865f into python:3.14 Nov 2, 2025
5 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 2, 2025
@picnixz
picnixz deleted the backport-f04bea4-3.14 branch July 5, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead approved these changes
+1 more reviewer
@hartwork hartwork hartwork approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@picnixz picnixz

Labels

topic-XML

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@picnixz @hartwork @gpshead
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.