CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-W67G-5RQW-F597

GHSA-W67G-5RQW-F597: Cryptographically Weak PRNG for WebSocket Frame Masking in Gorilla WebSocket

Amit Schendel
Amit Schendel
Senior Security Researcher

Aug 25, 2026·6 min read·20 visits

Executive Summary (TL;DR)

Gorilla WebSocket used math/rand instead of crypto/rand for masking keys, allowing attackers to predict key sequences and construct payloads that bypass proxy controls to perform request smuggling or cache poisoning.

A security vulnerability in the github.com/gorilla/websocket Go library allows remote attackers to predict client-to-server frame masking keys. This occurs because the library generates 32-bit mask keys using Go's non-cryptographically secure pseudo-random number generator (math/rand). Predicting these keys enables adversaries to bypass proxy-based security protections, facilitating HTTP request smuggling and cache poisoning attacks.

Vulnerability Overview

The vulnerability GHSA-W67G-5RQW-F597 targets the Go-based library github.com/gorilla/websocket, which is a widely utilized implementation of the WebSocket protocol. In WebSocket architectures, client-to-server frames must be masked using a 32-bit key to prevent intermediate HTTP proxies from misinterpreting raw TCP stream data as independent HTTP requests. This defensive mechanism is mandated by RFC 6455 to prevent request manipulation by untrusted client payloads.\n\nThe vulnerability resides in the implementation of the mask key generator, which relied on Go's standard library math/rand package prior to version 1.5.3. Because math/rand is a pseudo-random number generator designed for speed rather than cryptographic security, its outputs are fully deterministic once the seed or internal state is recovered. This design flaw exposes applications utilizing the client package to network-based attacks.\n\nAn attacker who is able to predict the sequence of generated mask keys can structure malicious payloads that, when XORed with the predicted mask key by the client, produce valid, unmasked HTTP request streams on the wire. This capability enables adversaries to conduct request smuggling, session hijacking, or cache poisoning on intermediate proxies that inspect the TCP connection. The vulnerability presents an integrity and confidentiality threat to communication paths crossing HTTP-aware network infrastructure.

Root Cause Analysis

The root cause of this vulnerability lies in the choice of PRNG used to generate the 32-bit frame masking keys. The math/rand package in Go employs an additive lagged Fibonacci generator with a recurrence relation defined by the state size of 607 64-bit integers. This mathematical design makes the generator vulnerable to complete state recovery once a sufficient quantity of consecutive outputs is observed by an attacker.\n\nUnder RFC 6455, every client frame must use a newly generated 32-bit key. Because the key space is small and the sequence generation is linear, an attacker observing approximately 1,214 consecutive 32-bit masking keys can reconstruct the 607-element internal state array of the generator. Alternatively, if the host application seeded the generator with a predictable value such as the system timestamp at startup, the initial seed can be brute-forced remotely.\n\nOnce the state is recovered, all future mask values produced by the client connection become deterministic. The attacker can predict the exact 32-bit XOR key that the client library will apply to the next outgoing frame. Because masking is a simple bitwise XOR operation, this predictability breaks the security assumptions of the WebSocket masking protocol, allowing the creation of specific traffic patterns that are interpreted differently by the endpoint and transit proxies.

Code Analysis

In versions of gorilla/websocket prior to 1.5.3, the mask key was generated in the newMaskKey function located within conn.go. The implementation invoked rand.Uint32() directly from the standard math/rand package. This function extracts pseudo-random bits from the default shared generator source.\n\nThe vulnerable code path is structured as follows:\n\ngo\n// Vulnerable implementation in gorilla/websocket/conn.go\nfunc newMaskKey() [4]byte {\n\tn := rand.Uint32() // Non-cryptographic PRNG\n\treturn [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)}\n}\n\n\nThe remediation commit d67f41855da42d7bccd9ef050c49f7e54e783b95 replaced this implementation with a secure read from crypto/rand. It introduced an unexported package-level variable maskRand initialized to rand.Reader, ensuring that the entropy is drawn from the operating system's cryptographic provider.\n\nThe patched code path is implemented as follows:\n\ngo\n// Patched implementation in gorilla/websocket/conn.go\nvar maskRand = rand.Reader // Defaults to crypto/rand.Reader\n\nfunc newMaskKey() [4]byte {\n\tvar k [4]byte\n\t_, _ = io.ReadFull(maskRand, k[:]) // Secure cryptographic read\n\treturn k\n}\n\n\nBy transitioning to crypto/rand.Reader, the library utilizes operating-system level entropy sources (such as /dev/urandom or getrandom system calls on Linux). This guarantees that each masking key is cryptographically secure and independent of prior keys, neutralizing state-reconstruction and seed-prediction vectors.

Exploitation Methodology

Exploitation of GHSA-W67G-5RQW-F597 requires the attacker to predict the masking key that the client library will assign to a future frame. To achieve this, the attacker first synchronizes with the client's PRNG state by sending multiple messages and capturing the output over the network. By reversing the XOR operation with known cleartext payloads, the attacker isolates the sequence of 32-bit mask keys.\n\nWith the PRNG state reconstructed, the attacker designs an HTTP request payload R intended to poison an intermediary HTTP cache. The attacker then calculates the malicious payload P by performing a bitwise XOR of R with the predicted mask key M. This calculated payload P is sent through the client WebSocket interface.\n\nmermaid\ngraph LR\n subgraph Attacker Infrastructure\n A["Calculate Payload: P = R XOR M"]\n end\n subgraph Client System\n B["WebSocket Client (Vulnerable)"]\n C["Apply Mask: Transmitted = P XOR M"]\n end\n subgraph Transit Network\n D["Intermediary Proxy (Reads Plaintext R)"]\n end\n subgraph Target Infrastructure\n E["Target Web Server / Cache"]\n end\n A --> B\n B --> C\n C -->|Sends Plaintext R| D\n D -->|Cache Poisoning / Smuggling| E\n\n\nWhen the client library prepares the frame for transmission, it applies the mask key M to the payload P. Because (R XOR M) XOR M = R, the actual bytes transmitted over the physical medium correspond exactly to the cleartext HTTP request R. An intermediate proxy inspecting the TCP flow reads R as a legitimate, separate HTTP transaction, leading to cache poisoning or request smuggling.

Impact Assessment

The security impact of predictable masking keys is primarily centered on the integrity of network proxy filters. It does not lead directly to remote code execution on the client or server, nor does it allow the exposure of local system memory. Instead, it systematically undermines the proxy-abuse protections designed into the RFC 6455 specification.\n\nIn environments where client traffic traverses corporate firewalls, reverse proxies, or content delivery networks (CDNs), the ability to bypass WebSocket frame isolation allows request smuggling. Attackers can inject arbitrary headers or split HTTP connections, potentially accessing unauthorized endpoints or poisoning downstream caches for other users. The CVSS score for this vulnerability is 6.9, reflecting network-accessible low integrity and confidentiality impacts.\n\nDue to the lack of a registered CVE identifier, this vulnerability does not appear in standard vulnerability databases such as the CISA KEV or the EPSS scoring registry. The exploit maturity is classified as proof-of-concept, as the algorithms for predicting lagged Fibonacci generators are well understood and widely documented, though specific, automated toolkits targeting this library in the wild are not currently observed.

Mitigation & Remediation

Remediation requires updating the github.com/gorilla/websocket dependency to version 1.5.3 or higher. This update changes the masking key generator to use cryptographically secure random bytes, preventing any predictability-based exploit attempts.\n\nTo apply the update using Go modules, execute the following commands in the project directory:\n\nbash\ngo get github.com/gorilla/websocket@v1.5.3\ngo mod tidy\n\n\nFor systems where upgrading the dependency is not immediately feasible, network-level workarounds can mitigate the risk. Enforcing transport layer security (TLS) for all WebSocket connections (using wss:// instead of ws://) prevents intermediate proxies from inspecting or parsing the payload stream. Since the data is encrypted in transit before reaching any proxies, the proxy cannot interpret the unmasked stream as a separate HTTP request.

Official Patches

gorillaOfficial fix replacing math/rand with crypto/rand in conn.go

Fix Analysis (1)

Technical Appendix

CVSS Score
6.9/ 10
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

Affected Systems

github.com/gorilla/websocket

Affected Versions Detail

Product
Affected Versions
Fixed Version
websocket
gorilla
< 1.5.31.5.3
AttributeDetail
CWE IDCWE-338
Attack VectorNetwork
CVSS Score6.9 (Medium)
EPSS ScoreN/A (No registered CVE)
ImpactHTTP Request Smuggling, Cache Poisoning
Exploit StatusProof-of-Concept
KEV StatusNot Listed

MITRE ATT&CK Mapping

T1600.001Weak Cryptography
Defense Evasion
T1557Adversary-in-the-Middle
Credential Access
T1102Web Service
Command and Control
CWE-338
Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)

The product uses a pseudo-random number generator (PRNG) in a security context, but the generator's algorithm is not cryptographically strong, making its output predictable.

Known Exploits & Detection

GitHub Security AdvisoryAdvisory outlining how predictable mask keys generated by math/rand permit proxy-cache poisoning and HTTP request smuggling.

Vulnerability Timeline

Vulnerability silently resolved in commit d67f41855da42d7bccd9ef050c49f7e54e783b95
2023-08-26
Version 1.5.3 officially released containing the fix
2023-08-26
GitHub Security Advisory GHSA-W67G-5RQW-F597 published
2026-08-24

References & Sources

  • [1]GitHub Security Advisory GHSA-W67G-5RQW-F597
  • [2]Vulnerability Patch Commit
  • [3]Gorilla WebSocket v1.5.3 Release Notes
  • [4]Advisory Source Reference

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•2 minutes ago•GHSA-GPWC-27CW-RH9R
5.3

CVE-2026-126301: Quadratic CPU Exhaustion in NLTK LegalitySyllableTokenizer

The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.

Amit Schendel
Amit Schendel
0 views•10 min read
•about 1 hour ago•CVE-2026-126304
8.7

CVE-2026-126304: Symlink Path Traversal in NLTK YCOECorpusReader

CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.

Amit Schendel
Amit Schendel
3 views•9 min read
•about 2 hours ago•CVE-2026-128077
6.5

CVE-2026-128077: Authorization Bypass via Request Path Desynchronization in Nuxt and @nuxt/nitro-server

CVE-2026-128077 (GHSA-r99w-jh2x-3mg9) is an authorization bypass and interpretation conflict vulnerability affecting Nuxt and its underlying @nuxt/nitro-server package in versions 4.6.0 through 4.6.3. When an incoming HTTP request path begins with a double forward slash (e.g., //x/admin), the WHATWG URL parser within the Nuxt server-side page renderer interprets the initial segment as a network host/authority and resolves the remaining path (/admin) against the application's page router. Because Nitro server middleware, route-scoped serverHandlers, and Nitro routeRules evaluate the unparsed request path (//x/admin), path-based access controls, redirects, and security header policies configured for /admin fail to match and are bypassed.

Amit Schendel
Amit Schendel
5 views•10 min read
•about 3 hours ago•CVE-2026-128084
4.8

CVE-2026-128084: Integer Truncation and SQL Query Truncation in sqlite3-ruby

Prior to version 2.10.2, the sqlite3-ruby gem explicitly cast 64-bit Ruby string lengths (long) to 32-bit signed integers (int) when invoking the underlying SQLite C API. On 64-bit platforms, providing a string of 4 GiB (2^32 bytes) or larger causes integer truncation, instructing SQLite to process only a prefix of the string. This flaw affects SQL query preparation, bound parameter values, and return values from custom Ruby-defined SQL functions and aggregates, allowing trailing SQL clauses such as WHERE restrictions to be silently dropped under specific conditions.

Alon Barad
Alon Barad
5 views•11 min read
•about 4 hours ago•CVE-2026-128068
5.3

CVE-2026-128068: Regular Expression Denial of Service in rails-html-sanitizer

CVE-2026-128068 (GHSA-cpgf-5mjf-73p7) is a Regular Expression Denial of Service (ReDoS) vulnerability in the rails-html-sanitizer Ruby gem affecting versions 1.0.3 through 1.7.1. The flaw resides in the Rails::HTML::PermitScrubber#scrub_attribute method, which uses the multiline regular expression /^\s*[^#\s].*/m to enforce local-only URI fragment references on SVG elements. On Ruby runtimes prior to version 3.2 (CRuby <= 3.1 and JRuby), evaluating an attribute value composed of repeated newline and whitespace characters without a hash character triggers quadratic backtracking O(n^2). Applications are only vulnerable if their sanitization allowlist is explicitly configured to permit SVG reference elements such as <use> alongside href or xlink:href attributes.

Alon Barad
Alon Barad
5 views•9 min read
•about 5 hours ago•CVE-2026-126360
5.3

CVE-2026-126360: Regular Expression Denial of Service in OpenTelemetry Python opentelemetry-api

CVE-2026-126360 (GHSA-mf5v-w3w3-f6cg) is an algorithmic complexity vulnerability (Regular Expression Denial of Service) in the trace context propagation logic of the opentelemetry-api package within the OpenTelemetry Python ecosystem. In versions prior to 1.45.2, the TraceContextTextMapPropagator.extract() method utilizes a regular expression susceptible to quadratic-time backtracking when parsing malformed W3C traceparent headers containing long sequences of whitespace followed by an embedded newline character. In Python applications—particularly those using single-threaded asynchronous event loops—an unauthenticated remote attacker transmitting payloads over newline-preserving carriers can monopolize CPU execution and induce application-level Denial of Service.

Alon Barad
Alon Barad
5 views•10 min read