Message335975
When using a policy for an EmailMessage that triggers folding (during serialization) of a fairly long display_name in an address field, the folding process removes the quotes from the display name breaking the semantics of the field.
In particular, for a From address's display name like r'[email protected] ' + 'a' * MAX_LINE_LEN the folding puts [email protected] unquoted immediately after the From: header. For applications that do sender verification inside and then send it to an internal SMTP server that does not perform its own sender verification this could be considered a security issue since it enables sender spoofing. Receiving mail servers might be able to detect the broken header, but experiments show that the mail gets delivered.
Simple demonstration (reproduced in attachment) of issue:
SMTP_POLICY = email.policy.default.clone(linesep='\r\n', max_line_length=72)
address = Address(display_name=r'[email protected] ' + 'a' * 72, addr_spec='[email protected]')
message = EmailMessage(policy=SMTP_POLICY)
message['From'] = Address(display_name=display_name, addr_spec=addr_spec)
# Trigger folding (via as_string()), then parse it back in.
msg_string = message.as_string()
msg_bytes = msg_string.encode('utf-8')
msg_deserialized = BytesParser(policy=SMTP_POLICY).parsebytes(msg_bytes)
# Verify badness
from_hdr = msg_deserialized['From']
assert from_hdr != str(address) # But they should be equal... |
|
| Date |
User |
Action |
Args |
| 2019-02-19 16:45:39 | aaryn.startmail | set | recipients:
+ aaryn.startmail, barry, r.david.murray |
| 2019-02-19 16:45:39 | aaryn.startmail | set | messageid: <[email protected]> |
| 2019-02-19 16:45:39 | aaryn.startmail | link | issue36041 messages |
| 2019-02-19 16:45:38 | aaryn.startmail | create | |
|