본문 바로가기
Secure Coding

서블릿 메소드 예외 처리 취약점

by Penetration Tester 2021. 9. 17.
728x90
반응형

서블릿 메소드 예외 처리 취약점

Noncompliant Code Example

public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws IOException, ServletException {
  String ip = request.getRemoteAddr();
  InetAddress addr = InetAddress.getByName(ip); // Noncompliant; getByName(String) throws UnknownHostException
  //...
}

 

Compliant Solution

public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws IOException, ServletException {
  try {
    String ip = request.getRemoteAddr();
    InetAddress addr = InetAddress.getByName(ip);
    //...
  }
  catch (UnknownHostException uhex) {
    //...
  }
}

728x90
반응형

'Secure Coding' 카테고리의 다른 글

로깅 인젝션 공격  (0) 2021.09.17
서버측 요청 위조 공격  (0) 2021.09.17
HTTP 응답 헤더 인젝션  (0) 2021.09.17
OS 명령 삽입 공격  (0) 2021.09.17
XPath 인젝션 공격  (0) 2021.09.17

댓글