New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggestion: deprecate/replace Filename.temp_file #3169
Comments
Comment author: administrator Dear Doug,
Correct.
Right.
Right. The reason for limiting the number of file names tried is that
The race condition is not as bad as that of mktemp() under Unix, A race remains, though: Filename.temp_file creates the file, then some
Right. I agree the file should be created with permission 0o600.
OK, here is what I'll implement shortly:
I hope this will address your concerns. Thanks for the feedback,
|
Comment author: administrator Implemented better temp_file and open_temp_file 2002-04-15, XL. |
Original bug ID: 829
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hello,
Since temporary file name vulnerabilities have been well-known by
security people and hackers alike, they make easy targets, so it's
probably best to avoid the possible problems by providing secure means
of obtaining temp files. It looks to like Filename.temp_file is
pretty unsecure, which makes me feel insecure, or something :-)
The problems with it are:
0 to 999.
they'd be doing lots of unecessary filesystem work.
attacker pre-creates all the 1000 files
there is a race condition before the user opens the tempfile
silly umask, their tempfile can even be overwritten. Even with a
normal umask like 022, their temp file will be world readable, so
private information could possibly be read.
I recommend that Filename.temp_file be deprecated and that 1 or 2 new
functions be created in Sys that correspond to the (safer and more
secure) glibc functions mkstemp(3)/tmpfile(3).
I may try implementing versions of these in pure Ocaml, just for
practice. If they could be of help, please let me know, but it might
be best to directly use the glibc functions.
cheers,
doug
The text was updated successfully, but these errors were encountered: