]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368)
authorStan Ulbrych <stan@python.org>
Tue, 9 Jun 2026 14:23:22 +0000 (15:23 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2026 14:23:22 +0000 (15:23 +0100)
commit19bc39127e5c916c42c54487a1ae68be76582f50
tree65ba4264d7735ce1e81031e11a44557890f54968
parentc68571c4bfe0b3f884ad753dcecf8d0f9085cc66
[3.13] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368)

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 f04bea44c37793561d753dd4ca6e7cd658137553,
and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack
(cherry picked from commit 666112376d574c7802646ee1df6244062671cd61)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Doc/library/pyexpat.rst
Include/pyexpat.h
Lib/test/test_pyexpat.py
Misc/NEWS.d/3.13.10.rst
Misc/NEWS.d/next/Library/2025-09-26-18-04-28.gh-issue-90949.YHjSzX.rst [new file with mode: 0644]
Modules/clinic/pyexpat.c.h
Modules/pyexpat.c