Skip to main content

CVE-2022-39218: CWE-335: Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG) in fastly js-compute-runtime

Medium
Published: Tue Sep 20 2022 (09/20/2022, 19:50:08 UTC)
Source: CVE
Vendor/Project: fastly
Product: js-compute-runtime

Description

The JS Compute Runtime for Fastly's Compute@Edge platform provides the environment JavaScript is executed in when using the Compute@Edge JavaScript SDK. In versions prior to 0.5.3, the `Math.random` and `crypto.getRandomValues` methods fail to use sufficiently random values. The initial value to seed the PRNG (pseudorandom number generator) is baked-in to the final WebAssembly module, making the sequence of random values for that specific WebAssembly module predictable. An attacker can use the fixed seed to predict random numbers generated by these functions and bypass cryptographic security controls, for example to disclose sensitive data encrypted by functions that use these generators. The problem has been patched in version 0.5.3. No known workarounds exist.

AI-Powered Analysis

AILast updated: 06/22/2025, 17:07:28 UTC

Technical Analysis

CVE-2022-39218 is a vulnerability identified in the JS Compute Runtime component of Fastly's Compute@Edge platform, specifically affecting versions prior to 0.5.3. The vulnerability arises from the incorrect usage of seeds in the pseudo-random number generator (PRNG) implementations of `Math.random` and `crypto.getRandomValues`. In these affected versions, the initial seed value for the PRNG is hardcoded (baked-in) within the compiled WebAssembly module. This design flaw causes the sequence of random numbers generated by these functions to be deterministic and predictable for that specific WebAssembly module instance. Since cryptographic operations often rely on strong randomness to ensure security properties such as confidentiality and integrity, the predictability of these random values can be exploited by attackers to bypass cryptographic controls. For example, an attacker could predict keys or nonces generated by these functions, potentially leading to the disclosure of sensitive data or enabling cryptographic attacks such as replay or forgery. The vulnerability is classified under CWE-335, which relates to the improper use of seeds in PRNGs, undermining the randomness quality. The issue was addressed and patched in version 0.5.3 of the js-compute-runtime. No known workarounds exist, and no exploits have been reported in the wild to date. The vulnerability does not require user interaction but does require the attacker to have access to or influence over the WebAssembly module using the affected runtime. The scope is limited to applications running on Fastly's Compute@Edge platform using the vulnerable versions of the runtime, which execute JavaScript code in edge environments.

Potential Impact

For European organizations leveraging Fastly's Compute@Edge platform with the vulnerable js-compute-runtime versions, this vulnerability poses a significant risk to the confidentiality and integrity of data processed or protected by cryptographic functions relying on the affected PRNG implementations. Predictable random values can lead to the compromise of encryption keys, session tokens, or other cryptographic artifacts, potentially exposing sensitive customer data or internal communications. This is particularly critical for industries with stringent data protection requirements such as finance, healthcare, and government services. Additionally, since Compute@Edge is often used to deploy edge computing workloads that handle real-time data processing and security enforcement closer to end users, exploitation could allow attackers to bypass security controls or manipulate data flows at the network edge. Although no exploits are known in the wild, the deterministic nature of the PRNG seed makes automated attacks feasible once the vulnerable module is identified. The impact on availability is limited, but the integrity and confidentiality risks are medium to high depending on the specific use case. Organizations relying on this platform for cryptographic operations should consider this vulnerability a priority to address to maintain compliance with European data protection regulations such as GDPR.

Mitigation Recommendations

The primary mitigation is to upgrade the js-compute-runtime to version 0.5.3 or later, where the PRNG seeding issue has been fixed. Since no workarounds exist, patching is the only effective remediation. Organizations should audit their usage of Fastly's Compute@Edge platform to identify any deployments using vulnerable versions of the runtime. Additionally, review and refactor any cryptographic code that depends on `Math.random` or `crypto.getRandomValues` within these environments to ensure they rely on secure randomness sources post-patch. Implement monitoring and logging to detect anomalous behaviors that might indicate attempts to exploit predictable randomness. Where possible, segregate sensitive cryptographic operations from edge environments or supplement with additional cryptographic safeguards such as hardware security modules (HSMs) or external key management services. Finally, maintain an inventory of all edge computing workloads and enforce strict version control and update policies for third-party runtimes and SDKs to prevent similar vulnerabilities from persisting.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-09-02T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9845c4522896dcbf441a

Added to database: 5/21/2025, 9:09:25 AM

Last enriched: 6/22/2025, 5:07:28 PM

Last updated: 7/30/2025, 9:58:08 PM

Views: 15

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats