This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: smtplib.SMTP.sendmail() does not provide transparency
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: avik, georg.brandl, loewis
Priority: normal Keywords:

Created on 2006-11-12 13:14 by avik, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg30518 - (view) Author: Avi Kivity (avik) Date: 2006-11-12 13:14
If the msg parameter to smtplib.SMTP.sendmail() 
contains a '\r\n.\r\n', the message will be 
terminated.  This will surprise most users, as 
smtplib should encapsulate the various protocol 
details rather than expose them.

It's also a potential security hole.  If 
user-supplied data is passed as msg, then the user 
may be able to inject SMTP commands by placing them 
after a '\r\n.\r\n'.

A workaround is to mutilate msg before passing it to 
smtplib.
msg30519 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-11-12 21:56
Logged In: YES 
user_id=21627

Would you like to contribute a patch to fix this problem?
msg30520 - (view) Author: Avi Kivity (avik) Date: 2006-11-12 22:00
Logged In: YES 
user_id=539971

Yes.  Do I need to submit it against 2.4 or 2.5, or both?
msg30521 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-11-12 22:07
Logged In: YES 
user_id=849994

As there were almost no changes in smtplib between 2.4 and
2.5, I think that 2.5 is enough, if someone backports it to
2.4, he can adapt if necessary.
msg30522 - (view) Author: Avi Kivity (avik) Date: 2006-11-12 23:05
Logged In: YES 
user_id=539971

Sorry, the report is completely bogus.  smtplib already does the necessary quoting.

I was getting truncated emails from a subversion commit hook, and jumped to conclusions.  
Turned out the commit hook was using the sendmail command, NOT smtplib (although it does 
have that option).

Sorry for the noise.
msg30523 - (view) Author: Avi Kivity (avik) Date: 2006-11-12 23:06
Logged In: YES 
user_id=539971

deleting.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44225
2006-11-12 13:14:19avikcreate