PSF-2026-8: email BytesGenerator header injection due to unquoted newlines
The email module, specifically the "BytesGenerator" class, didn’t properly quote newlines for email headers when serializing an email message allowing for header injection when an email is serialized. This is only applicable if using "LiteralHeader" writing headers that don't respect email folding rules, the new behavior will reject the incorrectly folded headers in "BytesGenerator".
Affected Software
Event History
Frequently Asked Questions
Which applications are exposed to this issue?
Applications are affected only if they use the Python email module's BytesGenerator to serialize messages and use LiteralHeader to write headers that do not comply with email folding rules.
What must an attacker be able to control?
An attacker would need to cause improperly folded header content containing unquoted newlines to be serialized through BytesGenerator. The resulting serialization can allow header injection.
Are normal email header-writing workflows affected?
The issue is described as applicable only to LiteralHeader usage for headers that do not respect email folding rules. The updated BytesGenerator behavior rejects those incorrectly folded headers.
What mitigation is available if an update cannot be applied immediately?
Avoid using LiteralHeader for headers that do not follow email folding rules, and ensure header values do not contain improperly folded or unquoted newlines before serializing messages with BytesGenerator.