客户潜力XSS jQuery

发布于 2025-02-10 23:00:18 字数 267 浏览 0 评论 0原文

我有以下问题,客户潜在的XS并试图修复它

$('#plazo input[value=' + $('#plazoActual').text() + ']').prop('checked', true);

但是我不明白为什么.text()是一个脆弱性

,希望某人经历的能力可以帮助您如何正确消毒上述行。

I have the following problem, Client Potential XSS and tried to fix it

$('#plazo input[value=' + $('#plazoActual').text() + ']').prop('checked', true);

but I don't understand why .text() is a vulnerability

Hope someone experienced can help, how to properly sanitize the above line.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飞烟轻若梦 2025-02-17 23:00:18

漏洞不是$('#plazoActual')。text(),而是您从页面中获取该值的事实(可能是用户可以编辑),并将其使用$()。报道了,因为$()可以创建元素,并且如果它是由串联用户输入创建的,则允许注入(XSS)。

乍一看,这种特殊情况似乎并不脆弱,因为上面的$()并没有创建元素,所以它只是输入字段的选择器(第一个字符是#,并且有一个空间)。我认为一般来说,这不能被利用,但是jQuery很久以前就具有各种漏洞,这也取决于确切的版本。另外,输入可能会被操纵,因此选择器在页面中找到了其他内容,这在更复杂的攻击中可能很有用。

一种更健壮,更安全的方法是在#plazo中找到所有输入(类似$('#plazo Input')),通过它们进行迭代,并设置<代码>检查其中值是$('#plazoactual')。text()。因此,关键是在选择器中没有动态内容。

The vulnerability is not $('#plazoActual').text(), but the fact that you take that value from the page (probably editable by a user), and use it in $(). It is reported, because $() can create elements, and if it's created from concatenated user input, it allows for injection (xss).

At first sight this particular case does not seem vulnerable though, because $() above does not create an element, it is just a selector for an input field (the first character is a # and there is a space). I think this cannot be exploited in general, but jQuery was a long time ago with all kinds of vulnerabilities also depending on the exact version. Also the input can potentially be manipulated so the selector finds something else in the page, which might be useful in a more complex attack.

A more robust and more secure way would be to find all inputs in #plazo (something like $('#plazo input')), iterate through them, and set checked where the value is $('#plazoActual').text(). So the point is to not have dynamic content in the selector.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文