Tre*_*eam 2 javascript security xss
我在我的应用程序中找到以下代码:
eval( 'window.opener.' + fct );
Run Code Online (Sandbox Code Playgroud)
变量fct来自GET参数(因此可以由用户更改).
是否有可能传递一些邪恶的价值来执行JavaScript?我不确定,因为如果您更改URL并将链接发送给用户,并且他点击它,"window.opener"将为null,因此将抛出错误:
eval( 'window.opener.x; alert(1);' ); // Uncaught TypeError: Cannot read property 'x' of null
Run Code Online (Sandbox Code Playgroud)
是否存在可能导致安全问题的攻击媒介?我知道,你永远不应该使用eval() - 但我也会尝试找到一个概念证明.
谢谢!
如果fct是,x = alert('yes')那么它将导致:
window.opener.x = alert('yes')
Run Code Online (Sandbox Code Playgroud)
并且将首先评估表达式的右侧,允许代码执行.
如果您不希望触发任何错误,您可以执行以下操作:
window.opener.x = (window.opener={pwnd:confirm('game over')})
Run Code Online (Sandbox Code Playgroud)