An application object, method or module can be overwritten with malicious logic due to the lack of validations and the nature of the JavaScript language.
- Overwrite or pollute the behavior of existing methods in the application.
- Lead to dangerous vulnerabilities such as XSS, SQLi, RCE, among others.
- Implement integrity validations on the vulnerable objects.
- Restrict and Discourage the use harmful properties such as _proto_ in the system objects.
Authenticated attacker from the Internet.
⌚ 60 minutes.
Default score using CVSS 3.1. It may change depending on the context of the src.
Default score using CVSS 4.0. It may change depending on the context of the src.
There are no harmful functionalities on vulnerable objects
function modifyPrototype(moduleName, deleteMethod, newMethod) {
var newMod = new moduleName;
//Add new method to the object, without altering the original
newMod.${newMethod} = function() {
//Add functionality to object
};
return newMod;
}
There are functionalities that can be overwritten due to insecure coding practices
function modifyPrototype(moduleName, deleteMethod, newMethod) {
// modifying the prototype of a module from within another function
var newMod = require(moduleName);
delete newMod[deleteMethod];
newMod.${newMethod} = function() {
// function body that modifies the original method
};
module.exports = newMod;
}