由于我负责的 php / IIS Web 应用程序中的反射 XSS 导致 PCI 合规性扫描失败,我刚刚收到报告。
可利用样本:
GET /login/recover/en?alert('TK00000105') HTTP/1.1
证据 :
<form id='recover_form_1' method='post'  action='https://www.somebody.com/login/recover/en?alert('TK00000105')' enctype='multipart/form-data'> 
输出由表单类生成,该类最近获得了在未提供完整操作的情况下提供完整操作的功能(JavaScript 增强和 HTML5 验证)。此操作是包含查询字符串的完整 URL(或多或少)。通常,查询字符串实际上是实际加载页面的决定因素(它并不完全友好!),所以我不能盲目地从 URL 中删除查询。
我应该如何(你如何)为表单操作清理 url,应该过滤的实际危险向量是什么?
去除 html 标签就足够了,还是唯一真正的方法来修补它以使每次使用表单都提供特定的操作?
------------------ 编辑表单创建的详细信息 --------------------------
构造和打开表单标签生成如下:
public function __construct( $id = false, $method = 'post', $action = '', $class= '')
    {        
        $this->_method = strtolower($method);
        $this->_action = $action;
        $this->_class =  $class;
        if ($id == false) 
        {
            FormEX::$_numForms++;
            $this->_id = 'form_'.FormEX::$_numForms."";
        } 
        else 
        {
            $this->_id = $id;
        }
        FormEX::Persist($this);
        $this->Controls = new \Collection(__NAMESPACE__.'\HTMLControl');
    }
...
     public function StartForm()
        {
            $action = $this->_action != '' ? $this->_action : $this->GenerateAction();
            $class = $this->_class != '' ? " class ='{$this->_class}'" : '';
            $enc = $this->_formEnctype != '' ? $this->_formEnctype : 'multipart/form-data';
            return "<form id='{$this->getID()}' method='{$this->_method}' $class action='$action' enctype='$enc'>";
        }
您将在控制器(或视图后面的其他位置)中创建表单,并在视图中使用如下内容:
<?if($this->form != null): ?>
    <?= $this->form->StartForm(); ?>
    <fieldset id="<?= $this->form->getID(); ?>">
        <div class='input'>
            <?= $this->form->_rc('Confirm'); ?>
            <?= $this->form->_rc('Cancel'); ?>
        </div>
    </fieldset>
    <?= $this->form->EndForm(); ?>
<?endif ?>
--------------------- 编辑 - 谢谢 Marek ------------- ------
因此,一项改进是确保对 url 进行编码,同时在输出点对所有开发人员可写属性进行防御性编码。
htmlentities($value, ENT_QUOTES, 'utf-8')_s() 是我们库中的编码快捷方式。
public function StartForm()
{
    $action = $this->_action != '' ? $this->_action : $this->GenerateAction();
    $class = $this->_class != '' ? " class ='{$this->_class}'" : '';
    $enc = $this->_formEnctype != '' ? $this->_formEnctype : 'multipart/form-data';
    $formTag = "<form id='" . _s($this->getID()) . "' method='" . _s($this->_method) . "' $class action='" . _s($action) . "' enctype='" . _s($enc) . "'>";
    return $formTag;
} 
关于我的问题,我还有什么需要注意的吗?
谢谢。