8.2
CWE
1321
Advisory Published
Advisory Published
Updated

CVE-2023-26158

First published: Fri Dec 08 2023(Updated: )

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 }

Credit: report@snyk.io

Affected SoftwareAffected VersionHow to fix
npm/mockjs<=1.1.0
Mock.js<=1.1.0

Never miss a vulnerability like this again

Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.

Frequently Asked Questions

  • What is the severity of CVE-2023-26158?

    CVE-2023-26158 is classified as a moderate severity vulnerability due to its potential for Prototype Pollution.

  • How do I fix CVE-2023-26158?

    To fix CVE-2023-26158, update the mockjs package to version 1.1.1 or later where the vulnerability is patched.

  • What impact does CVE-2023-26158 have on applications?

    CVE-2023-26158 can allow an attacker to modify or add attributes to the Object prototype, potentially affecting all objects in the application, leading to unexpected behavior.

  • Which versions of mockjs are affected by CVE-2023-26158?

    All versions of the mockjs package up to and including 1.1.0 are affected by CVE-2023-26158.

  • Is CVE-2023-26158 a common vulnerability?

    CVE-2023-26158 illustrates a common issue known as Prototype Pollution which can occur in many JavaScript libraries, making it a notable concern for developers.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2025 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203