Skip to content

Worst case quadratic complexity in HTMLParser #135462

Closed

Activity

  1. added 2 commits that reference this issue on Jun 13, 2025
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    3.11only security fixes
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Jun 13, 2025
  3. added a commit that references this issue on Jun 13, 2025
  4. added 2 commits that reference this issue on Jun 13, 2025
  5. 13 remaining items

  6. added a commit that references this issue on Jul 3, 2025
  7. serhiy-storchaka commented on Jul 4, 2025

    @serhiy-storchaka
    MemberAuthor

    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.

  8. added a commit that references this issue on Jul 12, 2025
  9. added a commit that references this issue on Jul 30, 2025
  10. added a commit that references this issue on Aug 4, 2025
  11. added a commit that references this issue on Aug 19, 2025
  12. added a commit that references this issue on May 14, 2026
  13. added 2 commits that reference this issue on Sep 18, 2026
  14. added 2 commits that reference this issue on Oct 1, 2026
  15. added a commit that references this issue on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.10 (EOL)end of life3.11only security fixes3.12only security fixes3.13only security fixes3.14bugs and security fixes3.15bugs and security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-securityA security issue

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions