Skip to content

email.utils.parseaddr(strict=True) silently splices inline comments in the local-part #159475

Description

@D3e4mlike

email.utils.parseaddr() and getaddresses(), even in strict=True mode (the default since the CVE-2023-27043 fix), silently drop a comment that is embedded inside a dot-atom and splice the surrounding atoms together:

>>> from email.utils import parseaddr
>>> parseaddr('u(comment)ser@d.com', strict=True)
('comment comment', 'user@d.com')

The strict parser rejects the same input:

>>> from email.headerregistry import Address
>>> Address(addr_spec='u(comment)ser@d.com')
InvalidHeaderDefect: local-part is not dot-atom, quoted-string, or obs-local-part

So a caller that validates or authorizes with parseaddr and then hands the original string to a strict component gets a subject mismatch — the same class as CVE-2019-11340 and the motivation for CVE-2023-27043.

Proposal: in strict mode, fail closed (return ('', '')) when a comment is embedded inside a dot-atom instead of splicing. strict=False would keep the historical lenient behavior. I'm happy to prepare a PR.

Reproduced on CPython 3.14.6.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 15, 2026
  2. added 2 commits that reference this issue on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions