【问题标题】:Prevent XSS attack in Paypal html form在 Paypal html 表单中防止 XSS 攻击
【发布时间】:2018-07-03 05:37:15
【问题描述】:

我在站点锁定上的 XSS 扫描有一些问题。他们说来自 html 输入表单的一些 URL 是易受攻击的。他们说我通过表格发送的每个参数都是易受攻击的。在这种情况下,漏洞来自 Paypal 输入表单。我使用 Paypal 重定向构建我的网站,因此用户将自己的数据输入到表单中,系统会将其发送到 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 漏洞?请知道的人可以帮助我。

【问题讨论】:

    标签: forms paypal xss


    【解决方案1】:

    我还建议使用 HTTP 标头。

    X-XSS-Protection: 1; mode=block
    

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection

    【讨论】:

    • 如果我有 xss 攻击页面将无法加载正确?
    • 此方法在检测到反射 XSS 攻击时阻止页面加载。
    【解决方案2】:

    您可能不会检查/取消您在输入字段中获取的数据

    在 billing_address 字段中输入 &lt;script&gt;alert('hacked')&lt;/script&gt;

    在您打印 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 的函数并为所有输入字段运行

    【讨论】:

      猜你喜欢
      • 2016-02-05
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      相关资源
      最近更新 更多