Security Considerations¶
The following modules have specific security considerations:
hashlib:all constructors take a “usedforsecurity” keyword-onlyargument disabling known insecure and blocked algorithmshttp.serveris not suitable for production use, only implementingbasic security checks. See thesecurity considerations.randomshouldn’t be used for security purposes, usesecretsinsteadshelve:shelve is based on pickle and thus unsuitable fordealing with untrusted sourcestempfile:mktemp is deprecated due to vulnerability to raceconditionszipfile:maliciously prepared .zip files can cause disk volumeexhaustion
The-I command line option can be used to run Python in isolatedmode. When it cannot be used, the-P option or thePYTHONSAFEPATH environment variable can be used to not prepend apotentially unsafe path tosys.path such as the current directory, thescript’s directory or an empty string.