Skip to content

Files

Latest commit

 

History

History
24 lines (15 loc) · 771 Bytes

B306.md

File metadata and controls

24 lines (15 loc) · 771 Bytes

Pattern: Use of insecure mktemp() function

Issue: -

Description

Use of this function may introduce a security hole in your program. By the time you get around to doing anything with the file name it returns, someone else may have beaten you to the punch. Use mkstemp() instead or replace with NamedTemporaryFile(), passing it the delete=False parameter.

Example of insecure code:

tempfile.mktemp('foo')

Example of secure code:

tempfile.mkstemp('foo')

Further Reading