【问题标题】:Anti-samy code will avoid the onclick in anchor link反samy代码将避免锚链接中的onclick
【发布时间】:2014-01-27 10:13:10
【问题描述】:

我正在使用 anti-samy 1.5.2 版本将我的 html 转换为安全的 html。

现在我给反samy扫描方法下面的代码

<a href='http://gmail.com' onclick="window.open(this.href,'','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,status'); return false">gmail.com</a>

但anti samy会将其转换为以下内容

<a href="http://javaEra.com">javaEra.com</a>

因此,我的 onclick 在我的应用程序中不起作用 所以我想要我给 antisamy 的相同代码

谁能帮帮我?

这里是我的锚标记的反 samy 策略文件

  <tag name="a" action="validate">

        <!--  onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid -->
        <attribute name="href"/>
        <attribute name="nohref">
            <regexp-list>
                <regexp name="anything"/>
            </regexp-list>
        </attribute>
        <attribute name="rel">
            <literal-list>
                <literal value="nofollow"/>
            </literal-list>
        </attribute>
        <attribute name="name"/>
        <attribute name="target" onInvalid="filterTag">
            <literal-list>
                <literal value="_blank"/>
                <literal value="_top"/>
                <literal value="_self"/>
                <literal value="_parent"/>
            </literal-list>
        </attribute>
    </tag>

【问题讨论】:

    标签: antisamy


    【解决方案1】:

    最后我得到了解决方案:只需将以下属性添加到锚标记 在上面的代码中替换如下

       <tag name="a" action="validate">
    
        <!--  onInvalid="filterTag" has been removed as per suggestion at OWASP SJ 2007 - just "name" is valid -->
        <attribute name="href"/>
        <attribute name="nohref">
            <regexp-list>
                <regexp name="anything"/>
            </regexp-list>
        </attribute>
        <attribute name="rel">
            <literal-list>
                <literal value="nofollow"/>
            </literal-list>
        </attribute>
        <attribute name="name"/>
        <attribute name="target" onInvalid="filterTag">
            <literal-list>
                <literal value="_blank"/>
                <literal value="_top"/>
                <literal value="_self"/>
                <literal value="_parent"/>
            </literal-list>
        </attribute>
        <attribute name="onclick">
           <regexp-list>
                <regexp name="anything"/>
            </regexp-list>
        </attribute>
    </tag>
    

    现在正在工作。

    【讨论】:

    • 此代码段将允许攻击者将 XSS 注入您的系统。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 2012-06-28
    • 1970-01-01
    • 1970-01-01
    • 2010-11-23
    • 1970-01-01
    相关资源
    最近更新 更多