Gorilla WebSocket weak PRNG for mask key generation

Severity: medium · CVSS 6.9 · Published 2026-08-24

Gorilla WebSocket is a popular Go library for building real-time bidirectional communication channels using the WebSocket protocol. Versions prior to 1.5.3 used a weak random number generator to create security tokens (mask keys) that protect WebSocket frames from tampering. An attacker who can predict these tokens could inject malicious data into WebSocket connections, potentially compromising the confidentiality and integrity of communications relying on this library.

Technologies: github.com/gorilla/websocket (Go). Vendors: Go.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Medium severity, with a CVSS score of 6.9, published 24 August 2026.
Which products and versions are affected?
github.com/gorilla/websocket (Go) < 1.5.3; Gorilla WebSocket < 1.5.3.
Is there a fix for This vulnerability?
A patch was published on 2026-06-14: Fix released in v1.5.3 (commit d67f4185) Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network, in a software library.
Am I affected?
Check whether you run github.com/gorilla/websocket (Go) or Gorilla WebSocket at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

Technical details

This vulnerability is a use of cryptographically weak PRNG (CWE-338). The root cause is that gorilla/websocket used Go's math/rand package to generate WebSocket frame masking keys prior to version 1.5.3. WebSocket masking keys must be unpredictable to prevent content injection attacks; however, math/rand produces deterministic output when seeded with a known value. An attacker with knowledge of the PRNG seed can predict or recover mask keys and inject content into WebSocket connections. The attack requires network access to a WebSocket connection but no authentication or user interaction. The fix, released in v1.5.3, replaces math/rand with crypto/rand (commit d67f4185), which provides cryptographically secure randomness.

Affected products

  • Gorilla WebSocket < 1.5.3

Timeline

  • 2026-06-12: disclosed: Advisory published to GitHub Security Advisory Database
  • 2026-08-24: advisory: Published to GitHub Advisory Database
  • 2026-06-14: patched: Fix released in v1.5.3 (commit d67f4185)

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.