CI 묻고 답하기

제목 XSS FILTER : TRUE 상태에서 POST 값이 사라지네요 CI 2.2.6 / PHP 5.1.6
글쓴이 JayT. 작성시각 2016/01/14 10:04:40
댓글 : 1 추천 : 0 스크랩 : 0 조회수 : 13325   RSS

안녕하세요..

 

3년전에 CI로 사이트 개발하고... 오랫만에 만져보네요.

 

현재 centos 5.1 / php 5.1.6  에서 ci 2.1.0으로 사이트를 개발하고 있습니다.

 

global_xss_filtering 값을 TRUE로 하면 POST 값이 전부 블랭크로 사라져버리네요..ㅠ

 

의심가는 부분은 development 모드에서 XSS 필터를 키면 아래와 같은 WARNING 메시지가 떴었습니다.

 

A PHP Error was encountered

Severity: Warning

Message: preg_replace_callback() [function.preg-replace-callback]: Compilation failed: unrecognized character after (?< at offset 5

Filename: core/Security.php

Line Number: 432

 

 

위 WARNING메시지의 해당 코드는 아래...

 

		$pattern = '#'
			.'<((?/*\s*)(?[a-z0-9]+)(?=[^a-z0-9]|$)' // tag start and name, followed by a non-tag character
			.'[^\s\042\047a-z0-9>/=]*' // a valid attribute character immediately after the tag would count as a separator
			// optional attributes
			.'(?(?:[\s\042\047/=]*' // non-attribute characters, excluding > (tag close) for obvious reasons
			.'[^\s\042\047>/=]+' // attribute characters
			// optional attribute-value
				.'(?:\s*=' // attribute-value separator
					.'(?:[^\s\042\047=><`]+|\s*\042[^\042]*\042|\s*\047[^\047]*\047|\s*(?U:[^\s\042\047=><`]*))' // single, double or non-quoted value
				.')?' // end optional attribute-value group
			.')*)' // end optional attributes group    <-- WARNING 메시지가 가리킨 423번줄 부분
			.'[^>]*)(?\>)?#isS';

		// Note: It would be nice to optimize this for speed, BUT
		//       only matching the naughty elements here results in
		//       false positives and in turn - vulnerabilities!
		do
		{
			$old_str = $str;
			$str = preg_replace_callback($pattern, array($this, '_sanitize_naughty_html'), $str);
		}
		while ($old_str !== $str);
		unset($old_str);

 

 

 

아래처럼 수정하면 WARNING은 뜨지 않으나 POST 값이 BLANK 되어버립니다.

 

$str = @preg_replace_callback($pattern, array($this, '_sanitize_naughty_html'), $str);

 

 다음글 table 라이브러리 초기화되는 현상 (6)
 이전글 500 에러 페이지를 커스텀 하고싶은데 방법이 있을까요... (1)

댓글

한대승(불의회상) / 2016/01/14 11:18:38 / 추천 0

ci 다른 버젼(2.2.1 ~ 2.2.6)으로 테스트를 해보시는게 좋을 것 같습니다.