小编eas*_*asa的帖子

JavaScript安全问题

我想知道以下函数如何设置'this'元素并获取数组单元格?请.

//my secure code
var priv = ['item-0','item-1'];
var api = {push: function(x){priv.push(x)}}

api.store = function(i,x){priv[i] = x}

//the attaker script
var result;
api.store('push',function(){result = this[0]});
api.push();

//the result is cell 0 of private array
//how?
//if i change the 'push' parameter then the result is empty!
document.write(result)
Run Code Online (Sandbox Code Playgroud)

javascript security this

1
推荐指数
1
解决办法
86
查看次数

标签 统计

javascript ×1

security ×1

this ×1