This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds adaptive connection acceptance rate limiting in the form of a lazy token bucket implementation, replacing the constant 1ms sleep in use before. The bucket contains a maximum of 100 tokens, replenished at a rate of one every 100ms; this allows a burst of up to 100 connection attempts without any delay, limiting to 10 per second thereafter under sustained load. Quiescence allows the bucket to refill back to its maximum, the intended effect being that initial network formation and partition healing are not hindered at all, but a sustained denial of service will be.
Testing reveals that this does not address the reported issue entirely - even at the lower bound of 10 requests per second there may not be enough entropy gathered on a headless system to keep pace. Nevertheless, after careful investigation and research, we have concluded that of the two options available to us (the other being implementing and seeding our own CSPRNG in a similar fashion to OpenSSL) this is by far the safest. We have been convinced that the impact of such an attack is limited to slowing
/dev/random
readers, so we have recorded our rationale along with links to supporting expert opinion in our cryptography design document.In closing, it is noteworthy that OpenSSH can be used to deplete entropy in exactly the same fashion, as each forked process consumes 256 bits from
/dev/urandom
.Closes #1037.