addslashes()是否可以安全地阻止HTML属性中的XSS?

编程入门 行业动态 更新时间:2024-10-28 18:36:47
本文介绍了addslashes()是否可以安全地阻止HTML属性中的XSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不得不处理以前的开发人员离开的旧网络应用程序。它使用addslashes()来防止HTTML属性上的XSS。

I'm having to work on an old web app that a previous developer left. It is using addslashes() to prevent XSS on a HTTML attribute.

这是一个例子:

<?php // all $_POST vars are put through addslashes() echo "<input type='hidden' value='" . $_POST['id'] . "' />"; ?>

这是否容易受到XSS攻击?有没有什么方法可以在一个值属性中运行javascript,就像在src属性中一样,例如,src ='javascript:alert(99)'。或者可以打开value属性,然后插入脚本标签?

Is this vulnerable to XSS? Is there any way javascript can run in a value attribute like it can in an src attribute for example, src='javascript:alert(99)'. Or can the value attribute be broken out of and then script tags can be inserted?

编辑:感谢Quentin,我认为它很容易受到攻击。

Thanks to Quentin, I believe it is vulnerable.

推荐答案

addslashes()是否可以安全地阻止HTML属性中的XSS?

Is addslashes() safe to prevent XSS in a HTML attribute?

非常无效。

这是否容易受到XSS攻击?

Is this vulnerable to XSS?

是。

有没有什么方法可以运行javascript像src属性中的值属性,例如,src ='javascript:alert(99)'。

Is there any way javascript can run in a value attribute like it can in an src attribute for example, src='javascript:alert(99)'.

或者可以打开value属性然后插入脚本标签吗?

Or can the value attribute be broken out of and then script tags can be inserted?

数据只需要包含一个,该属性就会被删除。

The data just has to include a " and the attribute is broken out of.

如果要插入任意字符串,请使用 htmlspecialchars n到属性值。

Use htmlspecialchars when you want to insert an arbitrary string into an attribute value.

更多推荐

addslashes()是否可以安全地阻止HTML属性中的XSS?

本文发布于:2023-07-30 04:38:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1246276.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   addslashes   HTML   XSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!