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

Websockets uses insecure random for Sec-WebSocket-Key and mask #437

Closed
chethega opened this issue Aug 18, 2019 · 1 comment
Closed

Websockets uses insecure random for Sec-WebSocket-Key and mask #437

chethega opened this issue Aug 18, 2019 · 1 comment

Comments

@chethega
Copy link

chethega commented Aug 18, 2019

Consider the this and this line.

Here, we use the base rand, which uses Mersenne twister. This is not a cryptographically secure random source.

Per rfc6455, "The masking key needs to be unpredictable; thus, the masking key MUST be derived from a strong source of entropy, and the masking key for a given frame MUST NOT make it simple for a server/proxy to predict the masking key for a subsequent frame."

After reading the websockets spec and the paper that lead to this requirement, this is not a severe problem. Still, would be better to fix this and use a secure random source.

A possibility could be to simply use const CSPRNG = Random.RandomDevice().

Cf general discussion here.

@quinnj
Copy link
Member

quinnj commented Jun 11, 2022

This is a good suggestion; a PR to implement this is here

@quinnj quinnj closed this as completed Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants