삶 가운데 남긴 기록 AACII.TISTORY.COM
JAVA 보안 URL Redirection to Untrusted Site 본문
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
https://cwe.mitre.org/top25/
cwe.mitre.org
'DEV&OPS > Java' 카테고리의 다른 글
JAVA 보안 Path Traversal (0) | 2022.08.05 |
---|---|
JAVA 보안 Cross-Site Request Forgery (0) | 2022.08.04 |
JAVA 보안 Unrestricted Upload of File with Dangerous Type (0) | 2022.08.04 |
JAVA 보안 OS Command Injection (0) | 2022.08.03 |
JAVA 보안 Cross-site Scripting (0) | 2022.08.03 |