2014-01-27 11 views
1

我正在使用反samy 1.5.2版本將我的html轉換爲安全的html。反samy代碼將避免鏈接中的onclick

現在我因爲這是我的onclick沒有在我的應用程序的工作給予以下代碼反薩米掃描方法

<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> 

但抗薩米將其轉換成以下

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

所以我想要我給antisamy的相同代碼

任何人都可以幫助我嗎?

這裏錨標記

<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> 

回答

1

我的反薩米政策文件,在最後我得到了這一個解決方案:只需添加folloing屬性定位標記 在上面的代碼替換像下面

<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> 

現在正在工作。

+1

此代碼段將允許攻擊者將XSS注入系統。 – avgvstvs