Skip to content

[3.10] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368) (#151401) - #155414

Merged
pablogsal merged 2 commits into
python:3.10from
StanFromIreland:backport-db195e3-3.10
Aug 10, 2026
Merged

[3.10] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368) (#151401)#155414
pablogsal merged 2 commits into
python:3.10from
StanFromIreland:backport-db195e3-3.10

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Aug 9, 2026

Copy link
Copy Markdown
Member

Expose the XML Expat 2.7.2 APIs to tune protections against "billion laughs" [1] attacks.

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

  • parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold), and
  • parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor).

This completes the work in f04bea4, and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack (cherry picked from commit 6661123) (cherry picked from commit 19bc391)

(cherry picked from commit db195e3)

… protections (pythonGH-139368) (python#151401)

Expose the XML Expat 2.7.2 APIs to tune protections against
"billion laughs" [1] attacks.

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

- `parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold)`, and
- `parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor)`.

This completes the work in f04bea4,
and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack
(cherry picked from commit 6661123)
(cherry picked from commit 19bc391)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
(cherry picked from commit db195e3)
@StanFromIreland

Copy link
Copy Markdown
Member Author

CC @python/windows-team any ideas as to why the Windows build failed?

@hugovk

hugovk commented Aug 10, 2026

Copy link
Copy Markdown
Member

Windows should pass now #153610 is merged.

@hugovk

hugovk commented Aug 10, 2026

Copy link
Copy Markdown
Member

macOS fix is #153312.

@StanFromIreland
StanFromIreland marked this pull request as ready for review August 10, 2026 09:07
@pablogsal
pablogsal merged commit 14c3f89 into python:3.10 Aug 10, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants