CVE-2021-23439: File upload with preview Cross-Site Scripting Vulnerability
MODERATECVE-2021-23439 is a MODERATE (CVSS 4.2) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting File upload with preview libraries in the npm ecosystem. The issue involves cross-site scripting in file-upload-with-preview. Remediation is available by upgrading affected packages to version 4.2.0.
CVE-2021-23439 at a Glance
Security Impact
CVSS: 4.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N).
How to Fix CVE-2021-23439
To remediate this vulnerability, upgrade all affected File upload with preview 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 file-upload-with-preview@4.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls file-upload-with-preview
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-23439, inspect your project dependencies using npm:
npm ls file-upload-with-preview
Analyze the terminal output to locate any version of File upload with preview in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.2.0), your application is affected.
Note: The npm ls file-upload-with-preview 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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In File upload with preview, 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-2021-23439 Affected File upload with preview Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
file-upload-with-preview
|
npm |
< 4.2.0
|
4.2.0
|
References
Frequently Asked Questions
What is CVE-2021-23439?
Which File upload with preview versions are affected?
What version fixes CVE-2021-23439?
Is file-upload-with-preview affected?
What is the CVSS score of CVE-2021-23439?
What CWE is associated with CVE-2021-23439?
How can I check npm dependencies for CVE-2021-23439?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-97pv-4338-r5vp",
"modified" : "2021-09-07T18:05:06Z",
"published" : "2021-09-07T23:08:54Z",
"aliases" : [ "CVE-2021-23439" ],
"summary" : "Cross-site Scripting in file-upload-with-preview",
"details" : "This affects the package file-upload-with-preview before 4.2.0. A file containing malicious JavaScript code in the name can be uploaded (a user needs to be tricked into uploading such a file).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "file-upload-with-preview"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-23439"
}, {
"type" : "WEB",
"url" : "https://github.com/johndatserakis/file-upload-with-preview/pull/40/files?file-filters%5B%5D=.js&hide-deleted-files=true%23diff-fe47b243de17419c0daa22cd785cd754baed60cf3679d3da1d6fe006f9f4a7f0R174"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/johndatserakis/file-upload-with-preview"
}, {
"type" : "WEB",
"url" : "https://github.com/johndatserakis/file-upload-with-preview/blob/develop/src/file-upload-with-preview.js%23L168"
}, {
"type" : "WEB",
"url" : "https://snyk.io/vuln/SNYK-JS-FILEUPLOADWITHPREVIEW-1579492"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-09-07T18:05:06Z",
"nvd_published_at" : "2021-09-05T14:15:00Z"
}
}