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 christian.heimes
Recipients christian.heimes
Date 2013-03-12.16:54:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1363107252.29.0.782882608.issue17405@psf.upfronthosting.co.za>
In-reply-to
Content
Compilers like GCC optimize away code like memset(var, 0, sizeof(var)) if the code occurs at the end of a function and var is not used anymore [1]. But security relevant code like hash and encryption use this to overwrite sensitive data with zeros.

The code in _sha3module.c uses memset() to clear its internal state. The other hash modules don't clear their internal states yet.


There exists a couple of solutions for the problem:

 * C11 [ISO/IEC 9899:2011] has a memset_s() function
 * MSVC has SecureZeroMemory()
 * GCC can disable the optimization with #pragma GCC optimize ("O0") since GCC 4.4
 * [2] contains an example for a custom implementation of memset_s() with volatile.

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537

[2] https://www.securecoding.cert.org/confluence/display/seccode/MSC06-C.+Be+aware+of+compiler+optimization+when+dealing+with+sensitive+data
History
Date User Action Args
2013-03-12 16:54:12christian.heimessetrecipients: + christian.heimes
2013-03-12 16:54:12christian.heimessetmessageid: <1363107252.29.0.782882608.issue17405@psf.upfronthosting.co.za>
2013-03-12 16:54:12christian.heimeslinkissue17405 messages
2013-03-12 16:54:11christian.heimescreate