fix #1813 레이아웃 미리보기 동작에 CSRF/XSS 방어 및 embed URL에 'act' parameter 사용 제한

- `layoutView::dispLayoutPreview()`에 XSS/CSRF 방어
- src, href, style 등 HTML attribute에 'act'를 포함하는 URL을 사용할 수 없도록 제한
This commit is contained in:
bnu 2015-12-08 15:11:55 +09:00
parent ca0fb36fb8
commit c1eab055bc
4 changed files with 42 additions and 54 deletions

View file

@ -1212,6 +1212,24 @@ function removeSrcHack($match)
}
}
$filter_arrts = array('style', 'src', 'href');
if($tag === 'object') array_push($filter_arrts, 'data');
if($tag === 'param') array_push($filter_arrts, 'value');
foreach($filter_arrts as $attr)
{
if(!isset($attrs[$attr])) continue;
$attr_value = rawurldecode($attrs[$attr]);
$attr_value = htmlspecialchars_decode($attr_value, ENT_COMPAT);
$attr_value = preg_replace('/\s+|[\t\n\r]+/', '', $attr_value);
if(preg_match('@(\?|&|;)(act=)@i', $attr_value))
{
unset($attrs[$attr]);
}
}
if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style']))
{
unset($attrs['style']);