Recent Posts
Recent Comments
Link
06-30 12:53
Today
Total
관리 메뉴

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

JAVA 보안 Reliance on Untrusted Inputs in a SecurityDecision 본문

DEV&OPS/Java

JAVA 보안 Reliance on Untrusted Inputs in a SecurityDecision

ALEPH.GEM 2022. 8. 17. 13:51

Reliance on Untrusted Inputs in a SecurityDecision 보호 메커니즘을 우회할 수 있는 입력값 변조

정의

공격자는 다양한 방법을 통해 입력값(쿠키,환경변수,히든필드 등)을 조작할 수 있고 조작된 내용은 탐지되지 않을 수 있습니다. 
따라서, 인증이나 인가 같은 보안 결정이 이런 입력값들을 기반으로 수행되면 보안을 우회할 수 있으므로 충분한 암호화 무결성 체크 등이 없는 경우 외부 입력값을 신뢰해서는 안됩니다.

 

방어 방법

상태 정보나 민감 데이터, 세션 정보 같은 중요한 정보는 서버에 저장하고 보안 절차도 서버에서 실행합니다.

 

안전하지 않은 예

Cookie[] cookies = request.getCookies();
for(int i = 0; i < cookies.length; i++){
    Cookie c = cookies[i];
    if(c.getName().equals("role")){
        userRole = c.getValue();
    }
}

위 예는 쿠키 값을 권한(role) 으로 사용하는 경우 사용자에 의해 변경된 경우 의도하지 않은 동작을 할 수 있습니다.

안전하게 하려면 서버측 세션 변수로 관리해야 합니다.

 

안전한 코드의 예

HttpSession session = context.getSession(id);
String userRole = (String)session.getValue("role");

 

 

 

참고

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

 

CWE - CWE-807: Reliance on Untrusted Inputs in a Security Decision (4.8)

div.collapseblock { display:inline} CWE-807: Reliance on Untrusted Inputs in a Security DecisionWeakness ID: 807Abstraction: BaseStructure: Simple The application uses a protection mechanism that relies on the existence or values of an input, but the input

cwe.mitre.org

 

 

 

 

 

 

728x90