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'anything@anything.com ' + 'a' * MAX_LINE_LEN the folding puts anything@anything.com 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'anything@anything.com ' + 'a' * 72, addr_spec='dev@local.startmail.org')
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: <1550594739.09.0.990893515193.issue36041@roundup.psfhosted.org> |
2019-02-19 16:45:39 | aaryn.startmail | link | issue36041 messages |
2019-02-19 16:45:38 | aaryn.startmail | create | |
|