← 返回首页
Slow IDNA decoding with large strings [CVE-2022-45061] · Issue #98433 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Slow IDNA decoding with large strings [CVE-2022-45061] #98433

New issue
New issue

Description

Bug report

Originally reported to the security address on September 9.

('xn--016c'+'a'*5000).encode('utf-8').decode('idna')

The execution time is not linear in relation to the input string size, which can cause slowness with large inputs:

10 chars = 0.016 seconds
100 chars = 0.047 seconds
1000 chars = 2.883 seconds
2500 chars = 17.724 seconds
5000 chars = 1 min 10 seconds

Comment by @tiran:

According to spec https://unicode.org/reports/tr46/ an IDNA label must not be longer than 63 characters. Python's idna module enforces the restriction, but too late.

This may be abused in some cases, for example by passing a crafted host name to asyncio create_connection:

import asyncio async def main(): loop = asyncio.get_running_loop() await loop.create_connection( lambda: [], ('xn--016c'+'a'*5000).encode('utf-8'), 443 ) asyncio.run(main())

Your environment

  • CPython versions tested on: CPython repository 'main' branch checkout, version 3.8.12, version 2.7.18
  • Operating system and architecture: Ubuntu Linux x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixes3.7 (EOL)end of life3.8 (EOL)end of life3.9 (EOL)end of lifetype-bugAn unexpected behavior, bug, or errortype-securityA security issue
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Footer

      © 2026 GitHub, Inc.