<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 22, 2017 at 7:10 PM, Giampaolo Rodola' <span dir="ltr"><<a href="mailto:g.rodola@gmail.com" target="_blank">g.rodola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Sat, Jul 22, 2017 at 6:38 PM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><span class="m_1940717517830257971gmail-"><div class="gmail_extra" dir="auto"><div class="gmail_quote">Le 22 juil. 2017 8:04 AM, "Serhiy Storchaka" <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>> a écrit :<blockquote class="m_1940717517830257971gmail-m_-372619920228489054quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I think the only reliable way of fixing the vulnerability is rejecting or escaping (as specified in RFC 2640) CR and LF inside sent lines. Adding the support of RFC 2640 is a new feature and can be added only in 3.7. And this feature should be optional since not all servers support RFC 2640. <a href="https://github.com/python/cpython/pull/1214" rel="noreferrer" target="_blank">https://github.com/python/cpyt<wbr>hon/pull/1214</a> does the right thing.<br></blockquote></div></div><div dir="auto"><br></div></span><div dir="auto">In that case, I suggest to reject newlines in ftplib, and maybe add an opt-in option to escape newlines.</div><div dir="auto"><br></div><div dir="auto">Java just rejected newlines, no? Or does Java allows to escape them?</div><span class="m_1940717517830257971gmail-HOEnZb"><font color="#888888"><div dir="auto"><br></div><div dir="auto">Victor</div><div class="gmail_extra" dir="auto"><div class="gmail_quote"><blockquote class="m_1940717517830257971gmail-m_-372619920228489054quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"></blockquote></div></div></font></span></div>
</blockquote></div><div class="gmail_extra"><br></div></div></div>OK, let's just reject \n then and be done with it. It's a rare use case after all.</div><div class="gmail_extra">Java just rejects \n for all commands and does not support escaping (aka RFC 2640).</div><span class=""><div class="gmail_extra"></div></span></div></blockquote></div><div class="gmail_extra"><br></div>I've just merged the PR. There's the question whether to backport this to older versions, considering there's a small chance this may break some code/apps, but considering the chance is small and this a security fix I'd probably be +0.5 for backporting it (2.7 + 3.x - not sure up 'till when).<br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Giampaolo - <a href="http://grodola.blogspot.com" target="_blank">http://grodola.blogspot.com</a></div><div><br></div></div></div>
</div></div>