【问题标题】:How to fix “Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)” in PHP output string如何在 PHP 输出字符串中修复“网页中与脚本相关的 HTML 标签的不正确中和(基本 XSS)”
【发布时间】:2017-12-17 22:56:41
【问题描述】:

我有以下 php 代码

<?php 
$Output = '<table><thead><tr>';
$Output .= '<th>Display</th></tr></thead><tbody>'; 
for ($k = 0; $k < count($ColumnsInSQL); $k++) { 
    $Output .= '<tr><td>'.$KS_ResultSet_level[$k][strtoupper(trim($ColumnsInSQL[$k]))].'</td></tr>';
}
$Output .= '</tbody></table>';
echo $Output;
?>

最近我在 Veracode 中运行代码,我遇到了"echo $Output;" 的问题。

谁能帮我解决这个问题?

【问题讨论】:

  • 你遇到了什么问题?
  • 在验证码扫描中,我遇到“网页中与脚本相关的 HTML 标记的不正确中和(基本 XSS)”问题
  • @Barmar,您的回答有效。非常感谢。

标签: php xss veracode


【解决方案1】:

使用htmlentities()对变量数据中的特殊字符进行编码。

$Output .= '<tr><td>'.htmlentities($KS_ResultSet_level[$k][strtoupper(trim($ColumnsInSQL[$k]))]).'</td></tr>';

【讨论】:

    猜你喜欢
    • 2020-03-24
    • 1970-01-01
    • 1970-01-01
    • 2014-03-21
    • 2014-09-30
    • 2014-05-13
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多