Array.prototype.test = 'test_prototype';
var arr = [1,2,3,4,5,6];
for (var i in arr){
console.log(i);
}
>>0
>>1
>>2
>>3
>>4
>>5
>>test
本文通过一个简单的JavaScript代码示例展示了如何进行原型污染,并解释了这种现象可能导致的安全问题。代码中修改了Array原型来添加一个非标准属性,这可能会影响所有使用Array的对象。
Array.prototype.test = 'test_prototype';
var arr = [1,2,3,4,5,6];
for (var i in arr){
console.log(i);
}
>>0
>>1
>>2
>>3
>>4
>>5
>>test
3万+

被折叠的 条评论
为什么被折叠?