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.

Author JohnLeitch
Recipients BreamoreBoy, JohnLeitch, belopolsky, brycedarling, eryksun, georg.brandl, larry, lemburg, paul.moore, python-dev, steve.dower, tim.golden, vstinner, zach.ware
Date 2015-09-06.20:59:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441573166.4.0.13243435706.issue24917@psf.upfronthosting.co.za>
In-reply-to
Content
First, let me begin by saying I believe this patch will fix the buffer over-read, which is a good step forward.

However, after giving the matter more thought, and at the risk of wearing out my welcome, I am of the belief that relying on the CRT to handle malformed format strings is the wrong approach. As per the C spec, strftime's behavior when handling invalid format strings is undefined:

"If a conversion specifier is not one of the above, the behavior is undefined"

Quite often, "undefined" translates to "exploitable". And at the very least, by not performing thorough enough validation, Python is misusing strftime(), which may lead to crashes or undermine memory safety. Of course, this is all speculation--I haven't the time or resource to learn other platforms to see what's possible. But, even if I could, the task would be Sisyphean because there's simply no way to know what the future holds when dealing with implementation that could change at any point.

I realize we must be pragmatic with matters such as this, and a dramatic change could be breaking for some Python apps. Even so, I feel it's worth vocalizing these concerns. As a principal, I think that "safe", well-formed Python should never be able to perform operations that lead to undefined behavior in the underlying runtime.

Alright, rant done. If at any point in time locking down Python's strftime with more aggressive validation is considered viable, I am more than willing to take a shot at submitting a patch.
History
Date User Action Args
2015-09-06 20:59:26JohnLeitchsetrecipients: + JohnLeitch, lemburg, georg.brandl, paul.moore, belopolsky, vstinner, larry, tim.golden, BreamoreBoy, python-dev, zach.ware, eryksun, steve.dower, brycedarling
2015-09-06 20:59:26JohnLeitchsetmessageid: <1441573166.4.0.13243435706.issue24917@psf.upfronthosting.co.za>
2015-09-06 20:59:26JohnLeitchlinkissue24917 messages
2015-09-06 20:59:25JohnLeitchcreate