Vulnerabilities in pkg:npm/mockjs
PACKAGECVE-2023-26158 is a HIGH (CVSS 8.2) mockjs vulnerable to prototype pollution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Mockjs libraries in the npm ecosystem. The issue involves mockjs vulnerable to prototype pollution via the util.extend function. Remediation is available in the latest vendor maintenance releases.
pkg:npm/mockjs
Vulnerability advisories affecting package pkg:npm/mockjs. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-mh8j-9jvh-gjf6 | CVE-2023-26158 | HIGH | mockjs vulnerable to Prototype Pollution via the Util.extend function |
CVE-2023-26158 at a Glance
Security Impact
CVSS: 8.2
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:N/S:U/C:N/I:L/A:H).
How to Fix CVE-2023-26158
To remediate this vulnerability, upgrade all affected Mockjs 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 mockjs@Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mockjs
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2023-26158, inspect your project dependencies using npm:
npm ls mockjs
Analyze the terminal output to locate any version of Mockjs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The npm ls mockjs 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-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In Mockjs, 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-2023-26158 Affected Mockjs Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mockjs
|
npm |
≤ 1.1.0
|
|
References
Frequently Asked Questions
What is CVE-2023-26158?
Which Mockjs versions are affected?
What version fixes CVE-2023-26158?
Is mockjs affected?
What is the CVSS score of CVE-2023-26158?
What CWE is associated with CVE-2023-26158?
How can I check npm dependencies for CVE-2023-26158?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mh8j-9jvh-gjf6",
"modified" : "2023-12-08T15:49:13Z",
"published" : "2023-12-08T06:30:38Z",
"aliases" : [ "CVE-2023-26158" ],
"summary" : "mockjs vulnerable to Prototype Pollution via the Util.extend function",
"details" : "All versions of the package mockjs are vulnerable to Prototype Pollution via the Util.extend function due to missing check if the attribute resolves to the object prototype. By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the software depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf).\n\nUser controlled inputs inside the extend() method of the Mock.Handler, Mock.Random, Mock.RE.Handler or Mock.Util, will allow an attacker to exploit this vulnerability.\n\n Workaround\n\nBy using a denylist of dangerous attributes, this weakness can be eliminated.\n\nAdd the following line in the Util.extend function:\n\njs\njs if ([\"__proto__\", \"constructor\", \"prototype\"].includes(name)) continue\n\n\njs\n// src/mock/handler.js\nUtil.extend = function extend() {\n var target = arguments[0] || {},\n i = 1,\n length = arguments.length,\n options, name, src, copy, clone\n\n if (length === 1) {\n target = this\n i = 0\n }\n\n for (; i < length; i++) {\n options = arguments[i]\n if (!options) continue\n\n for (name in options) {\n if ([\"__proto__\", \"constructor\", \"prototype\"].includes(name)) continue\n src = target[name]\n copy = options[name]\n\n if (target === copy) continue\n if (copy === undefined) continue\n\n if (Util.isArray(copy) || Util.isObject(copy)) {\n if (Util.isArray(copy)) clone = src && Util.isArray(src) ? src : []\n if (Util.isObject(copy)) clone = src && Util.isObject(src) ? src : {}\n\n target[name] = Util.extend(clone, copy)\n } else {\n target[name] = copy\n }\n }\n }\n\n return target\n }\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mockjs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "1.1.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-26158"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nuysoft/Mock"
}, {
"type" : "WEB",
"url" : "https://github.com/nuysoft/Mock/blob/00ce04b92eb464e664a4438430903f2de96efb47/dist/mock.js#L721-L755"
}, {
"type" : "WEB",
"url" : "https://security.snyk.io/vuln/SNYK-JS-MOCKJS-6051365"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1321" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2023-12-08T15:49:13Z",
"nvd_published_at" : "2023-12-08T05:15:07Z"
}
}