Skip to content

Open Redirect 취약점 #318

@arrester

Description

@arrester

Security 탭에서 제보가 불가능하여 Issues를 통해 제보드립니다.

Vuln: Open Redirect

Version: 5.5.16

url 파라미터에서 역슬래시에 대한 필터링이 존재하지 않아 Open Redirect 취약점이 발생합니다.

아래는 공격 증명 코드(PoC)이며 원하는 도메인으로 지정한 상태로 테스트할 수 있습니다.

PoC

https://demo.sir.kr/gnuboard5/bbs/logout.php?url=\google.com
https://demo.sir.kr/gnuboard5/bbs/logout.php?url=\github.com

Impact

  • 피싱 사이트로 연계한 공격이 발생할 수 있습니다.

Secure Code (bbs/logout.php)

아래는 \ 역슬래시를 탐지할 수 있는 예시 시큐어코드입니다.

if ($url) {
    if ( substr($url, 0, 2) == '//' )
        $url = 'http:' . $url;

    **if (preg_match('#\\\0#', $url) || preg_match('/^\/{1,}\\\/', $url) || preg_match('/\\\/', $url))** {
        alert('url 에 올바르지 않은 값이 포함되어 있습니다.', G5_URL);
    }

    $p = @parse_url(urldecode(str_replace('\\', '', $url)));
    /*
        // OpenRediect 취약점관련, PHP 5.3 이하버전에서는 parse_url 버그가 있음 ( Safflower 님 제보 ) 아래 url 예제
        // http://localhost/bbs/logout.php?url=http://sir.kr%23@/
    */
    if (preg_match('/^https?:\/\//i', $url) || $p['scheme'] || $p['host']) {
        alert('url에 도메인을 지정할 수 없습니다.', G5_URL);
    }

    if($url == 'shop')
        $link = G5_SHOP_URL;
    else
        $link = $url;
} else if ($bo_table) {
    $link = get_pretty_url($bo_table);
} else {
    $link = G5_URL;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions