2014-01-27 2 views
1

내 html을 안전한 html로 변환하기 위해 anti-samy 1.5.2 버전을 사용하고 있습니다.Anti-samy 코드는 앵커 링크에서 onclick을 피할 것입니다.

지금 내가 인해 내 onclick을 내 응용 프로그램에서 작동하지 않는이에

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

다음에이 변환됩니다 방지 새미 스캔 방법

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

하지만 안티 새미에게 다음 코드를 제공하고있다 그래서 나는 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