我对sitelock上的XSS扫描有一些问题。他们说,html输入表单中的一些URL是易受攻击的。他们说我通过表单发送的每个参数都是易受攻击的。在这种情况下,该漏洞来自Paypal输入表单。我建立我的网站与贝宝重定向,所以用户将输入自己的数据到表单和系统将其发送到贝宝。这是我的表单代码示例:
<div class="col-md-5">
<input type="text" class="form-control" name="L_PAYMENTREQUEST_FIRSTNAME" id="L_PAYMENTREQUEST_FIRSTNAME" value="<?=$_SESSION['post_value']['shipping_first_name']?>" readonly="readonly">
</div>
<input type="hidden" name="billing_first_name" value="<?=$_POST['billing_first_name']?>">
<input type="hidden" name="billing_last_name" value="<?=$_POST['billing_last_name']?>">
<input type="hidden" name="billing_email" value="<?=$_POST['billing_email']?>">
<input type="hidden" name="billing_phone" value="<?=$_POST['billing_phone']?>">
<input type="hidden" name="billing_address" value="<?=$_POST['billing_address']?>">
<input type="hidden" name="billing_city" value="<?=$_POST['billing_city']?>">
<input type="hidden" name="billing_postcode" value="<?=$_POST['billing_postcode']?>">
<input type="hidden" name="billing_state" value="<?=$_POST['billing_state']?>">这是我表单的一部分。我想知道的是那个表单有什么问题,如何防止Sitelock扫描XSS漏洞?请任何认识的人都能帮到我。
发布于 2018-07-03 13:52:33
您可能没有检查/取消在输入字段中获取的数据
并在billing_address字段中键入<script>alert('hacked')</script>
在打印billing_address的下一页上,您将看到一个名为hacked的弹出窗口
在处理表单的页面上,您应该验证输入字段没有任何javascript代码。
例如
<?php
// define variables and set to empty values
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = test_input($_POST["name"]);
$email = test_input($_POST["email"]);
$website = test_input($_POST["website"]);
$comment = test_input($_POST["comment"]);
$gender = test_input($_POST["gender"]);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>您需要创建一个类似于test_input的函数,并对所有输入字段运行
发布于 2018-07-03 14:01:29
我还建议使用HTTP标头。
X-XSS-Protection: 1; mode=blockhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
https://stackoverflow.com/questions/51147288
复制相似问题