classification
Title: email: AttributeError
Type: behavior Stage: resolved
Components: email Versions: Python 3.8
process
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.

Files
File name Uploaded Description Edit
file0.zip 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.

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


Traceback:
    msg = email.message_from_binary_file(f)
  File "/usr/lib/python3.5/email/__init__.py", line 62, in message_from_binary_file
    return BytesParser(*args, **kws).parse(fp)
  File "/usr/lib/python3.5/email/parser.py", line 110, in parse
    return self.parser.parse(fp, headersonly)
  File "/usr/lib/python3.5/email/parser.py", line 57, in parse
    feedparser.feed(data)
  File "/usr/lib/python3.5/email/feedparser.py", line 178, in feed
    self._call_parse()
  File "/usr/lib/python3.5/email/feedparser.py", line 182, in _call_parse
    self._parse()
  File "/usr/lib/python3.5/email/feedparser.py", 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 triager) 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.
History
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