CVE-2023-26158
n/a mockjs: Improperly Controlled Modification of Object Prototype Attributes
Check your servers for CVE-2023-26158
The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2023-26158 affects mockjs, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.
Description
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).
User 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.
Workaround
By using a denylist of dangerous attributes, this weakness can be eliminated.
Add the following line in the Util.extend function:
js js if (["__proto__", "constructor", "prototype"].includes(name)) continue
js // src/mock/handler.js Util.extend = function extend() { var target = arguments[0] || {}, i = 1, length = arguments.length, options, name, src, copy, clone
if (length === 1) { target = this i = 0 }
for (; i < length; i++) { options = arguments[i] if (!options) continue
for (name in options) { if (["__proto__", "constructor", "prototype"].includes(name)) continue src = target[name] copy = options[name]
if (target === copy) continue if (copy === undefined) continue
if (Util.isArray(copy) || Util.isObject(copy)) { if (Util.isArray(copy)) clone = src && Util.isArray(src) ? src : [] if (Util.isObject(copy)) clone = src && Util.isObject(src) ? src : {}
target[name] = Util.extend(clone, copy) } else { target[name] = copy } } }
return target }
Severity (CVSS)
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H/E:P
- Attack vector
- network: an attacker can reach the vulnerable part over the network, often from the internet
- Attack complexity
- low: an attack works without special conditions
- Privileges required
- none: the attacker does not need an account
- User interaction
- none: nobody has to click or open anything
- Scope
- unchanged: the damage stays inside the vulnerable component
- Impact
- confidentiality none, integrity low, availability high: what an attacker can read (confidentiality), change (integrity) or stop (availability)
Exploitation
EPSS 0.81%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 58.0% of all scored CVEs. Scores of 1 Dec 2026.
Weakness
- CWE-1321 Improperly Controlled Modification of Object Prototype Attributes
Affected products
As the CNA lists them.
| Product | Versions |
|---|---|
|
mockjs
n/a
|
affected all versions
|
Is my server affected?
Find the installed version of mockjs and compare it with the fixed version of your distribution. Distributions often fix a CVE in a package version of their own, so the version number of the upstream project can mislead.
Debian, Ubuntu
dpkg -l | grep -i mockjs
# packages whose changelog names the CVE (fixed in the installed version)
zgrep -l CVE-2023-26158 /usr/share/doc/*/changelog.Debian.gz
# Ubuntu
pro fix CVE-2023-26158RHEL, Rocky, Alma, Fedora
rpm -q mockjs
# lists the advisory while the fix is not installed
dnf updateinfo list --cve CVE-2023-26158Alpine
apk list --installed | grep -i mockjsWith Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:
trivy rootfs --scanners vuln / | grep CVE-2023-26158
trivy image --scanners vuln IMAGE | grep CVE-2023-26158
Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.
References
Other references
- https://security.snyk.io/vuln/SNYK-JS-MOCKJS-6051365 security.snyk.io
- https://github.com/nuysoft/Mock/blob/00ce04b92eb464e664a4438430903f2de96efb47/dist/mock.js%23L721-L755 github.com
Source: the record CVE-2023-26158 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST; the CWE catalog of MITRE, CWE Terms of Use. The text of the record is shown as published. Data sources and licences.
Vulnpocalypse