Vulnerabilities in pkg:npm/@strapi/plugin-upload
PACKAGECVE-2024-31217 is a MODERATE (CVSS 5.3) @strapi/plugin-upload has a denial-of-service vulnerability (CWE-248: Uncaught Exception) affecting @strapi/plugin upload libraries in the npm ecosystem. The issue involves @strapi/plugin-upload has a denial-of-service via improper exception handling. Remediation is available by upgrading affected packages to version 4.22.0.
pkg:npm/@strapi/plugin-upload
Vulnerability advisories affecting package pkg:npm/@strapi/plugin-upload. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-pm9q-xj9p-96pm | CVE-2024-31217 | MODERATE | @strapi/plugin-upload has a Denial-of-Service via Improper Exception Handling |
CVE-2024-31217 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2024-31217
To remediate this vulnerability, upgrade all affected @strapi/plugin upload dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @strapi/plugin-upload@4.22.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @strapi/plugin-upload
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-31217, inspect your project dependencies using npm:
npm ls @strapi/plugin-upload
Analyze the terminal output to locate any version of @strapi/plugin upload in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.22.0), your application is affected.
Note: The npm ls @strapi/plugin-upload command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-248: Uncaught Exception, where an exception is thrown from a function, but it is not caught. In @strapi/plugin upload, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-31217 Affected @strapi/plugin upload Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@strapi/plugin-upload
|
npm |
< 4.22.0
|
4.22.0
|
References
Frequently Asked Questions
What is CVE-2024-31217?
Which @strapi/plugin upload versions are affected?
What version fixes CVE-2024-31217?
Is @strapi/plugin-upload affected?
What is the CVSS score of CVE-2024-31217?
What CWE is associated with CVE-2024-31217?
How can I check npm dependencies for CVE-2024-31217?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-pm9q-xj9p-96pm",
"modified" : "2024-06-12T19:38:24Z",
"published" : "2024-06-12T19:38:24Z",
"aliases" : [ "CVE-2024-31217" ],
"summary" : "@strapi/plugin-upload has a Denial-of-Service via Improper Exception Handling",
"details" : "### Summary\nA Denial-of-Service was found in the media upload process causing the server to crash without restarting, affecting either development and production environments.\n\n### Details\nUsually, errors in the application cause it to log the error and keep it running for other clients. This behavior, in contrast, stops the server execution, making it unavailable for any clients until it's manually restarted. \n\n### PoC\nDue to a bug in what we believe to be Burp’s decoding system, we couldn’t produce a valid file to easily reproduce the vulnerability. Instead, the issue can be reproduced by following these steps:\n1. Configure Burp’s proxy between a browser and a Strapi server\n2. Log in and upload an image through the Media Library page while having Burp’s interceptor turned on\n3. After capturing the upload POST request in Burp, add `%00` at the end of the file extension from the `Content-Disposition`, in the filename parameter (See reference image 1 below)\n4. Using the cursor, select the added `%00` and right-click it. Click in Convert selection > URL > URL decode to transform the selected text into a null byte\n5. Forward the modified request. The server should print an error and crash with the error `ERR_INVALID_ARG_VALUE` (See reference log 1 below)\n\nBy following the data flow, we reached the [line of code](https://github.com/strapi/strapi/blob/f1dd5cc8eef574bac6679aab6f93276e57497328/packages/providers/upload-local/src/index.ts#L86) where we believe the DoS is being caused.\nThe simpler way of fixing this vulnerability seems to be avoiding the error thrown by whitelisting the characters used in the extension.\n\n#### Reference Image 1\n\n\n#### Reference Log 1\n```\n[2024-03-22 10:23:42.629] http: POST /upload (22 ms) 400\nnode:internal/fs/utils:379\n const err = new ERR_INVALID_ARG_VALUE(\n ^\n\nTypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '/mnt/storage/Development/GHSA-pm9q-xj9p-96pm/public/uploads/replaceme_png_88efe6a165.png\\x00'\n at new WriteStream (node:internal/fs/streams:340:5)\n at Object.createWriteStream (node:fs:3123:10)\n at /mnt/storage/Development/GHSA-pm9q-xj9p-96pm/node_modules/@strapi/provider-upload-local/dist/index.js:71:33\n at new Promise (<anonymous>)\n at Object.uploadStream (/mnt/storage/Development/GHSA-pm9q-xj9p-96pm/node_modules/@strapi/provider-upload-local/dist/index.js:68:16)\n at Object.uploadStream (/mnt/storage/Development/GHSA-pm9q-xj9p-96pm/node_modules/@strapi/plugin-upload/server/register.js:80:35)\n at Object.upload (/mnt/storage/Development/GHSA-pm9q-xj9p-96pm/node_modules/@strapi/plugin-upload/server/services/provider.js:16:46)\n at Object.uploadImage (/mnt/storage/Development/GHSA-pm9q-xj9p-96pm/node_modules/@strapi/plugin-upload/server/services/upload.js:220:48) {\n code: 'ERR_INVALID_ARG_VALUE'\n}\n```\n\n### Impact\nDenial-of-Service occurs when a service becomes unavailable for users or other services.\nBy sending a specially-crafted request, the server crashes without restarting. The entire server crashes with the thrown error instead of crashing only the single request and returning error 500 to the user.\nAny user with access to the file upload functionality is able to exploit this vulnerability, affecting applications running in both development mode and production mode as well.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@strapi/plugin-upload"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.22.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/strapi/strapi/security/advisories/GHSA-pm9q-xj9p-96pm"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-31217"
}, {
"type" : "WEB",
"url" : "https://github.com/strapi/strapi/commit/a0da7e73e1496d835fe71a2febb14f70170135c7"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/strapi/strapi"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-248" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-06-12T19:38:24Z",
"nvd_published_at" : "2024-06-12T15:15:51Z"
}
}