Vulnerabilities |
5 via 5 paths |
|---|---|
Dependencies |
107 |
Source |
GitHub |
Find, fix and prevent vulnerabilities in your code.
critical severity
new
- Vulnerable module: node-forge
- Introduced through: @parse/node-apn@8.2.0
Detailed paths
-
Introduced through: @parse/push-adapter@parse-community/parse-server-push-adapter › @parse/node-apn@8.2.0 › node-forge@1.4.2
Overview
node-forge is a JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.
Affected versions of this package are vulnerable to Improper Certificate Validation via pki.verifyCertificateChain() in lib/x509.js, which does not decode or enforce the X.509 nameConstraints extension (OID 2.5.29.30) during certificate path validation. A certificate authority whose nameConstraints extension is marked non-critical can issue a leaf certificate with a subjectAltName dNSName or subject commonName outside its permitted subtrees or inside its excluded subtrees, and the chain passes verification. This allows an attacker holding such a CA's private key, or able to obtain a certificate issued under it, to impersonate arbitrary names - including in TLS peer verification via forge.tls - defeating the namespace restriction the constraint was intended to enforce.
Note: This is only exploitable when a name-constrained CA with a non-critical nameConstraints extension chains to a root trusted by the application, and the attacker controls that CA's private key or can obtain an out-of-scope certificate from it. Chains without nameConstraints are unaffected, and chains with a critical nameConstraints extension were already rejected.
Workaround
Pass an options.verify callback to pki.verifyCertificateChain() (or verify to forge.tls.createConnection()) that returns an error when any CA certificate in the chain has an extension with id 2.5.29.30. This rejects all chains below a name-constrained CA, including valid ones. Trust anchors with the extension must be checked separately.
Remediation
Upgrade node-forge to version 1.4.3 or higher.
References
high severity
new
- Vulnerable module: node-forge
- Introduced through: @parse/node-apn@8.2.0
Detailed paths
-
Introduced through: @parse/push-adapter@parse-community/parse-server-push-adapter › @parse/node-apn@8.2.0 › node-forge@1.4.2
Overview
node-forge is a JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.
Affected versions of this package are vulnerable to NULL Pointer Dereference via tls.handleHandshake() in lib/tls.js, which attempts to update handshake digests via c.session.md5.update(bytes) when c.session is null. A client's session is set to null by c.reset() after a close_notify alert or a call to close(), and is also absent before handshake() is called. A malicious server or an on-path attacker can send a ServerHello record in any of these states, causing an uncaught TypeError to propagate out of connection.process() and terminate the Node.js process.
Note: Only forge.tls clients are affected; servers are not vulnerable because a server creates its session upon receiving a ClientHello.
PoC
var c = forge.tls.createConnection({server: false, ...});
c.handshake();
// warning close_notify alert, then an empty ServerHello, in separate
// process() calls
c.process(forge.util.hexToBytes('15030100020100'));
c.process(forge.util.hexToBytes('160301000402000000'));
// <= 1.4.2: TypeError: Cannot read properties of null (reading 'md5')
// 1.4.3: the record is ignored
The reporter's PoC is in tests/pocs/ghsa-j8rw-jp99-435v.js, and regression tests are in tests/unit/tls.js.
Remediation
Upgrade node-forge to version 1.4.3 or higher.
References
high severity
new
- Vulnerable module: node-forge
- Introduced through: @parse/node-apn@8.2.0
Detailed paths
-
Introduced through: @parse/push-adapter@parse-community/parse-server-push-adapter › @parse/node-apn@8.2.0 › node-forge@1.4.2
Overview
node-forge is a JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via _trimString() in lib/http.js, which removes trailing whitespace using the regular expression /\s*$/. On a string of n whitespace characters followed by a non-whitespace character, the engine attempts a match at each position and scans the remainder of the run each time, producing O(n^2) work. forge.http calls _trimString() on every response header value processed by response.readHeader() and on cookie names and values in response.getCookies(), with no limit on header size. A server or on-path attacker can send a large response header that blocks the client's event loop for minutes, denying service to everything else in the process.
Note: This is only exploitable by applications that use forge.http directly; forge.http is not loaded by require('node-forge') and requires a socket pool provided by the application.
Workaround
Limit the size of HTTP response headers before passing them to forge.http, for example in the socket pool's data handler.
PoC
var response = forge.http.createResponse();
var ws = new Array(40001).join('\t ');
response.readHeader(forge.util.createBuffer(
'HTTP/1.1 200 OK\r\nX-A: a' + ws + 'X\r\n\r\n'));
// <= 1.4.2: about 4 seconds (quadratic in the whitespace length)
// 1.4.3: about 1 ms
Regression tests are in tests/security/ghsa-6cv4-p8m7-4r25.js.
Details
Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.
The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.
Let’s take the following regular expression as an example:
regex = /A(B|C+)+D/
This regular expression accomplishes the following:
AThe string must start with the letter 'A'(B|C+)+The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the+matches one or more times). The+at the end of this section states that we can look for one or more matches of this section.DFinally, we ensure this section of the string ends with a 'D'
The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD
It most cases, it doesn't take very long for a regex engine to find a match:
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total
$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total
The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.
Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.
Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:
- CCC
- CC+C
- C+CC
- C+C+C.
The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.
From there, the number of steps the engine must use to validate a string just continues to grow.
| String | Number of C's | Number of steps |
|---|---|---|
| ACCCX | 3 | 38 |
| ACCCCX | 4 | 71 |
| ACCCCCX | 5 | 136 |
| ACCCCCCCCCCCCCCX | 14 | 65,553 |
By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.
Remediation
Upgrade node-forge to version 1.4.3 or higher.
References
high severity
new
- Vulnerable module: node-forge
- Introduced through: @parse/node-apn@8.2.0
Detailed paths
-
Introduced through: @parse/push-adapter@parse-community/parse-server-push-adapter › @parse/node-apn@8.2.0 › node-forge@1.4.2
Overview
node-forge is a JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.
Affected versions of this package are vulnerable to Uncaught Exception via tls.parseHelloMessage() in lib/tls.js, which stores the ServerHello's compression_method without validating it against the methods offered in the ClientHello. When the client subsequently handles ServerHelloDone, tls.createConnectionState() throws an uncaught Error('Unsupported compression algorithm.') for any compression method other than null (0) or deflate (1). Because the ServerHello is not yet authenticated at this point, a malicious server or an on-path attacker can set the compression byte to an unsupported value, causing connection.process() to throw and terminating the Node.js process in applications that do not catch the exception - including those using forge.tls.wrapSocket or forge.http.
Workaround
Catch exceptions thrown by connection.process() and close the socket.
PoC
A server (or on-path attacker) sends a ServerHello with `compression_method` 0xff, followed by a valid Certificate and ServerHelloDone:
client.handshake();
client.process(serverHello + certificate + serverHelloDone);
// <= 1.4.2: throws Error: Unsupported compression algorithm.
// 1.4.3: error callback with "Unsupported compression method."
The reporter's PoC (a CA-issued server certificate and the default verify callback) is in tests/pocs/ghsa-w4xr-hqv8-ch44.js, and regression tests are in tests/unit/tls.js.
Remediation
Upgrade node-forge to version 1.4.3 or higher.
References
medium severity
new
- Vulnerable module: node-forge
- Introduced through: @parse/node-apn@8.2.0
Detailed paths
-
Introduced through: @parse/push-adapter@parse-community/parse-server-push-adapter › @parse/node-apn@8.2.0 › node-forge@1.4.2
Overview
node-forge is a JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.
Affected versions of this package are vulnerable to Improper Verification of Cryptographic Signature via ed25519.verify() in lib/ed25519.js, which does not reject public keys of small order. crypto_sign_open() decodes the public key A with unpackneg(), which only checks that the point is on the curve, and never validates that the key is not a small-order point (the identity point or the other 7 points of order 2, 4, or 8, including non-canonical encodings with y >= p). An attacker who can supply the public key can present a small-order key together with a signature where S = 0 and a small-order R, causing the verification equation R == [k](-A) to hold for many or all messages without knowledge of any private key. For the identity key specifically, the fixed signature R = identity, S = 0 verifies for every message.
PoC
Identity public key `A = 01 00 … 00` (32 bytes) and signature `R = 01 00 … 00`, `S = 00 … 00` (64 bytes):
forge.ed25519.verify({message: 'admin=true', encoding: 'utf8',
signature: SIG, publicKey: IDENTITY});
// <= 1.4.2: true for any message; node:crypto.verify(): false
// 1.4.3: false
Other small-order public keys (orders 2, 4 and 8, and non-canonical encodings) give forgeries for many messages with `S = 0` and a small-order `R`.
Regression tests are in tests/unit/ed25519.js, and the reporter's PoC is in tests/pocs/ghsa-6889-vf6x-f3g5.js.
Remediation
Upgrade node-forge to version 1.4.3 or higher.
References
medium severity
- Module: web-push
- Introduced through: web-push@3.6.7
Detailed paths
-
Introduced through: @parse/push-adapter@parse-community/parse-server-push-adapter › web-push@3.6.7
MPL-2.0 license