gpt4 book ai didi

javascript - XSS - 寻找对 JSON.decode for mootools 请求的评论的解释

转载 作者:行者123 更新时间:2023-11-30 12:48:00 25 4
gpt4 key购买 nike

所以我在 Mootools 文档中查看 Request 并注意到最近发布的一条评论,内容如下...

"Be aware of XSS vulnerability: Default value for secure is falsy, which means that JSON.decode("alert(document.cookie)") shows a popup !"

JSON.decode 方法的文档是这样说的:

JSON Method:Decode

Converts a JSON string into a JavaScript object.

Syntax:

var object = JSON.decode(string[, secure]);

Arguments:

string - (string) The string to evaluate.

secure - (boolean, optional: defaults to false) If set to true, checks for any hazardous syntax and returns null if any found.

Returns: (object) The object represented by the JSON string.

因此,根据文档,我很清楚 JSON.decode 方法默认设置为“不安全”。不过,我的问题是与 XSS 有什么关系(如果有的话),以及我帖子顶部的评论是否有值(value)。假设您在前端使用 Mootools,并且您信任您进行 AJAX 调用的地址,这怎么可能是 XSS 安全漏洞?

http://mootools.net/docs/core/Utilities/JSON

最佳答案

这里的问题是eval().

自“回到过去”以来,JSON.parse() 之前Mootools 诞生 used eval返回解析后的 JSON。所以这里的问题和discussed here about eval()是一样的.

如果您只为现代浏览器编写代码,请选择 vanilla JSON.parse() .如果您需要低至 IE6 的跨浏览器,那么 Mootools 会为您完成这项工作 ™ Mootools 为开发人员提供了强大的工具,如果您不想要,请打开 secure 选项/参数使用评估。

关于javascript - XSS - 寻找对 JSON.decode for mootools 请求的评论的解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21902571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com