Recent Posts
Recent Comments
Link
07-02 05:38
Today
Total
관리 메뉴

삶 가운데 남긴 기록 AACII.TISTORY.COM

JAVA 보안 URL Redirection to Untrusted Site 본문

DEV&OPS/Java

JAVA 보안 URL Redirection to Untrusted Site

ALEPH.GEM 2022. 8. 4. 15:58

URL Redirection to Untrusted Site

사용자의 입력값을 외부 사이트 주소로 사용해서 자동으로 연결하는 서버 프로그램은 피싱 공격에 취약점이 있습니다.

자동 연결할 외부 사이트의 URL은 화이트 리스트로 관리해서 방어합니다.

 

안전하지 않은 예

...
String url = request.getParameter("url");
response.sendRedirect(url);
...

안전한 예

//다른 사이트로 이동하는 URL 화이트 리스트를 만든다.
String allowURL[] = {"https://url1.com", "https://url2.com", "https://url3.com"};

String nurl = request.getParameter("nurl");
try{
    Integer n = Integer.parseInt(nurl);
    if(n >= 0 && n < 3){
      response.sendRedirect(allowURL[n]);
    }
}catch(NumberFormatException nfe){
    //사용자의 입력값이 숫자가 아닌경우 에러를 처리
    ...
}

 

 

 

참고

http://cwe.mitre.org/data/definitions/601.html

 

CWE - CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (4.8)

div.collapseblock { display:inline} CWE-601: URL Redirection to Untrusted Site ('Open Redirect')Weakness ID: 601Abstraction: BaseStructure: Simple A web application accepts a user-controlled input that specifies a link to an external site, and uses that li

cwe.mitre.org

https://www.owasp.org/index.php

 

OWASP Foundation, the Open Source Foundation for Application Security | OWASP Foundation

OWASP Foundation, the Open Source Foundation for Application Security on the main website for The OWASP Foundation. OWASP is a nonprofit foundation that works to improve the security of software.

owasp.org

http://cwe.mitre.org/top25

 

https://cwe.mitre.org/top25/

 

cwe.mitre.org

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90