php - 具有 xss 漏洞的搜索字段
问题描述
我的搜索字段中有一个 XSS 漏洞,当我输入典型警报('xss')时,窗口就会出现。我使用 vega 和 OWASP ZAP 来了解我的错在哪里,我已经检测到,它在带下划线的代码中,但我不知道如何清理,你能帮我吗?这是我的代码:
<?php
require_once("../include/pictures.php");
require_once("../include/comments.php");
require_once("../include/cart.php");
require_once("../include/html_functions.php");
require_once("../include/functions.php");
session_start();
if (!isset($_GET['query']))
{
http_redirect("/error.php?msg=Error, need to provide a query to search");
}
$pictures = Pictures::get_all_pictures_by_tag($_GET['query']);
?>
<?php our_header("", $_GET['query']); ?>
<div class="column prepend-1 span-24 first last">
<h2>Pictures that are tagged as '<?= $_GET['query'] ?>'</h2>
<?php thumbnail_pic_list($pictures); ?>
</div>
<?php our_footer(); ?>
我不能下划线,需要清理的代码是:
'<?= $_GET['query'] ?>'
解决方案
用这个
htmlspecialchars($_GET['query'])
推荐阅读
- python - python 包安装在 pipenv 中,但说没有找到模块
- javascript - 如何使用toggle_visibility隐藏div然后在点击时显示另一个div
- android-studio - 如何运行谷歌新的“places_compat_compatify.sh”兼容性脚本?
- javascript - 由于范围问题未设置值
- javascript - 如何手动清理自调用函数创建的调用堆栈
- delphi - VCL界面,DBGrid在滚动和调整大小时感觉呆滞
- ionic-framework - 如何在 ionic3 滑块选项中添加引导程序(介绍页面)
- c# - 为什么自定义控件的属性不会显示在 Visual Studio 编辑器中?
- java - 在同一个类中使用@provide 和@Inject
- javascript - 字符串附加字符串的python奇怪结果