도

XSS 취약점 신고합니다

· 2013-11-05 (화) 23:01:56 · 2109 · 1
<object type="application/x-shockwave-flash" width="560" height="315" dummy='>'>
<param name="movie" value="xss.swf"></param>
<param name="allowscriptaccess" value="always"></param>
</object>

이렇게 올리면 XSS가 됩니다.

object 태그와 같은 복잡한 태그를 정규식만으로 처리하기는 어렵습니다.

object 태그를 허용하지 않고 embed만 허용 하는건 어떤지요?

첨부파일은 간단한 xss 필터입니다.
이것만으로도 최신 브라우저(ie8 및 그 이상)에서 거의 모든 xss 공격은 막을 수 있습니다.

[code]
function xss_filter($content)
{
// Strip bad elements.
$content = preg_replace('/(<)(|\/)(\!|\?|html|head|title|meta|body|style|link|base|script'.
'|frameset|frame|noframes|applet|object|param|iframe|noscript|noembed|basefont|xmp|plaintext|comment)/i',
'<$2$3', $content);

// Strip script handlers.
$content = preg_replace_callback("/([^a-z])(o)(n)/i",
create_function('$matches', 'if($matches[2]=="o") $matches[2] = "o";
else $matches[2] = "O"; return $matches[1].$matches[2].$matches[3];'), $content);

// Embed
$content = str_ireplace('<embed', '<embed allowscriptaccess="never"' , $content);

return $content;
}

[/code]

첨부파일

xss_filter.php (679 bytes) 21회 2013-11-05 23:01
|

댓글 1개

2013-11-06 (수) 11:47:56
오~~~ 이건 굿팁이네
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
13-11-06 조회 1,682
13-11-06 조회 2,019
13-11-06 조회 1,685
13-11-06 조회 2,670
13-11-06 조회 1,393
13-11-06 조회 1,604
13-11-06 조회 1,324
13-11-06 조회 1,290
13-11-06 조회 1,377
13-11-06 조회 1,262
13-11-06 조회 1,107
13-11-06 조회 1,160
13-11-06 조회 2,438
13-11-06 조회 1,760
13-11-06 조회 1,772
13-11-06 조회 1,772
13-11-06 조회 1,419
13-11-06 조회 1,225
13-11-05 조회 2,182
13-11-05 조회 2,110