Prototype Pollution to RCE
可能受到影响的代码
const { execSync, fork } = require('child_process');
function isObject(obj) {
console.log(typeof obj);
return typeof obj === 'function' || typeof obj === 'object';
}
// Function vulnerable to prototype pollution
function merge(target, source) {
for (let key in source) {
if (isObject(target[key]) && isObject(source[key])) {
merge(target[key], source[key]);
} else {
target[key] = source[key];
}
}
return target;
}
function clone(target) {
return merge({}, target);
}
// Run prototype pollution with user input
// Check in the next sections what payload put here to execute arbitrary code
clone(USERINPUT);
// Spawn process, this will call the gadget that poputales env variables
// Create an a_file.js file in the current dir: `echo a=2 > a_file.js`
var proc = fork('a_file.js');通过环境变量实现PP2RCE
污染 __proto__
__proto__DNS 交互
PP2RCE漏洞child_process函数
强制执行Spawn
控制require文件路径
相对路径加载 - 1
相对路径 require - 2
VM Gadgets
Fixes & Unexpected protections
其他 Gadgets
References
最后更新于