Skip to content
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

feat: re-seed from system randomness on collision #314

Merged
merged 1 commit into from
Jan 2, 2025
Merged

Conversation

Stebalien
Copy link
Owner

Re-seed thread-local RNG from system randomness if we run into a temporary file-name collision. This should address the concerns about using a predictable RNG without hurting performance in the common case where nobody is trying to predict our filenames. I'm only re-seeding once because if we still fail to create a temporary file, the collision was likely due to too many temporary files instead of an attacker predicting our random temporary file names.

I've also reduced the number of tries from 2^31 to 2^16. If it takes more than that to create a temporary file, something else is wrong. Pausing for a long time is usually worse than just failing.

fixes #178

Re-seed thread-local RNG from system randomness if we run into a
temporary file-name collision. This should address the concerns about
using a predictable RNG without hurting performance in the common case
where nobody is trying to predict our filenames. I'm only re-seeding
once because if we _still_ fail to create a temporary file, the
collision was likely due to too many temporary files instead of an
attacker predicting our random temporary file names.

I've also reduced the number of tries from 2^31 to 2^16. If it takes
more than that to create a temporary file, something else is wrong.
Pausing for a long time is usually worse than just failing.

fixes #178
@Stebalien Stebalien merged commit ea45f47 into master Jan 2, 2025
14 checks passed
@Stebalien Stebalien deleted the steb/reseed branch January 2, 2025 21:41
Stebalien added a commit that referenced this pull request Jan 3, 2025
Alternative to #311 (this patch includes a few miscellaneous
documentation fixes from that PR as well).

The previous documentation didn't sufficiently cover permissions issues
and mixed all the security concerns into a single section. This patch
separates things out into separate sections and hopefully makes all this
easier to understand.

This patch also documents the DOS mitigation introduced in #314.

I've also removed the link to the OWASP documentation to avoid confusing
users (their documentation is mostly concerned with low-level C and
platform-specific temporary file creation functions).
Stebalien added a commit that referenced this pull request Jan 5, 2025
Alternative to #311 (this patch includes a few miscellaneous
documentation fixes from that PR as well).

The previous documentation didn't sufficiently cover permissions issues
and mixed all the security concerns into a single section. This patch
separates things out into separate sections and hopefully makes all this
easier to understand.

This patch also documents the DOS mitigation introduced in #314.

I've also removed the link to the OWASP documentation to avoid confusing
users (their documentation is mostly concerned with low-level C and
platform-specific temporary file creation functions).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of predictable RNG
1 participant