Worst case quadratic complexity in HTMLParser #135462
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-securityA security issueA security issue
Description
Linked PRs
- gh-135462: Fix quadratic complexity in processing special input in HTMLParser #135464
- [3.14] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) #135481
- [3.13] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) #135482
- [3.12] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) #135483
- [3.11] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) #135484
- [3.10] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) #135485
- [3.9] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) #135486
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-securityA security issueA security issue
Projects
- StatusShow more project fieldsDone
Activity
pythongh-135462: Fix quadratic complexity in processing special input…
pythongh-135462: Fix quadratic complexity in processing special input…
gh-135462: Fix quadratic complexity in processing special input in HT…
pythongh-135462: Fix quadratic complexity in processing special input…
pythongh-135462: Fix quadratic complexity in processing special input…
13 remaining items
[3.12] gh-135462: Fix quadratic complexity in processing special inpu…
serhiy-storchaka commentedon Jul 4, 2025
Some more information.
The issue was reported by Jake Howard on behalf of the Django Security team.
The problem is that when the parser found the beginning of an element (tag, commet, etc), it looked for its end (this has linear complexity), and when it didn't find it, it emitted the beginning as data and started with the next "<". And it could find a new beginning in the middle of an incomplete element, so it continued over and over again, making the total complexity quadratic. There are many ways to trigger this.
The HTML5 standard specifies the behavior for unexpectedly terminated elements, it does not require backtracking, so the total complexity is linear. #135464 implements this.
pythongh-135462: Fix quadratic complexity in processing special input…
[3.9] pythongh-135462: Fix quadratic complexity in processing special…
pythongh-135462: Fix quadratic complexity in processing special input…
pythongh-135462: Fix quadratic complexity in processing special input…
CVE-2025-6069 python/cpython#135462
CVE-2025-6069 python/cpython#135462
[CVE-2025-6069] fix quadratic complexity in processing special input …
[CVE-2025-6069] fix quadratic complexity in processing special input …
[CVE-2025-6069] fix quadratic complexity in processing special input …
[CVE-2025-6069] fix quadratic complexity in processing special input …
fix: pin Python 3.12.15 repo-wide for CVE-2025-6069 (HTMLParser quadr…