Title: email: AttributeError
Type: behavior Stage: resolved
Components: email Versions: Python 3.8
Status: closed Resolution: duplicate
Dependencies: Superseder: Certain Malformed email causes email.parser to throw AttributeError
View: 36910
Assigned To: Nosy List: Jeffrey.Kintscher, alter-bug-tracer, barry, maxking, msapiro, r.david.murray, xtreak
Priority: normal Keywords:

Created on 2019-05-20 18:19 by alter-bug-tracer, last changed 2019-06-01 16:33 by berker.peksag. This issue is now closed.

File name Uploaded Description Edit alter-bug-tracer, 2019-05-20 18:19
Messages (3)
msg342940 - (view) Author: alter-bug-tracer (alter-bug-tracer) * Date: 2019-05-20 18:19
The 'lower' method is called on a Header object when trying to parse the attached file.

import email
import sys
with open(sys.argv[1], "rb") as f:
  msg = email.message_from_binary_file(f)
  print (len(msg))

    msg = email.message_from_binary_file(f)
  File "/usr/lib/python3.5/email/", line 62, in message_from_binary_file
    return BytesParser(*args, **kws).parse(fp)
  File "/usr/lib/python3.5/email/", line 110, in parse
    return self.parser.parse(fp, headersonly)
  File "/usr/lib/python3.5/email/", line 57, in parse
  File "/usr/lib/python3.5/email/", line 178, in feed
  File "/usr/lib/python3.5/email/", line 182, in _call_parse
  File "/usr/lib/python3.5/email/", line 322, in _parsegen
    if (self._cur.get('content-transfer-encoding', '8bit').lower()
AttributeError: 'Header' object has no attribute 'lower'
msg342941 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-05-20 18:24
See also issue36910 which seems to be similar report on non-ascii Content-Transfer-Encoding which is present in the reported file0 file too.
msg342942 - (view) Author: alter-bug-tracer (alter-bug-tracer) * Date: 2019-05-20 18:33
It is actually the exact same bug. At that time we were not sure if it security related or not, so we disclosed it privately and discussed it with Mark. We were not aware that he has submitted it for us.
Date User Action Args
2019-06-01 16:33:24berker.peksagsetstatus: open -> closed
superseder: Certain Malformed email causes email.parser to throw AttributeError
resolution: duplicate
stage: resolved
2019-05-28 08:33:17Jeffrey.Kintschersetnosy: + Jeffrey.Kintscher
2019-05-20 18:33:56alter-bug-tracersetmessages: + msg342942
2019-05-20 18:24:56xtreaksetnosy: + maxking, barry, r.david.murray, msapiro, xtreak
messages: + msg342941
components: + email
2019-05-20 18:19:58alter-bug-tracercreate