-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Improve randomness of uploaded file names and files created by tempnam() #14364
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the randomness is used and processed LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Uploaded files are created with a name in the form
/tmp/phpXXXXXX
, whereXXXXXX
is given one of 62^6 different values bymkstemp(3)
. According to this blogpost, it is possible to guess this name by brute forcing, with a reasonable number of attempts. This can be used to exploit a vulnerable applications.Here I add 64 bits of additional randomness before the
XXXXXX
pattern, to make this attack unpractical.The change also applies to tempnam() and to platforms without
mkstemp()
.