티스토리 뷰

Web

HTTP Method 제한

Pure Sage 2018. 4. 24. 14:24

참조 링크

http://duco777.blog.me/220765466402

http://kdsr2z0.github.io/HttpMethodLimit/

http://www.4te.co.kr/572


공공기관 홈페이지 보안관련 규정 중, '웹 서비스 메소드 설정 공격'이라는 항목이 있다.


일반적으로 사용하는 GET, POST 메소드 이외의 PUT, DELETE, COPY, MOVE 등의 불필요한 메소드를 허용하였을 경우 공격자가 이를 이용하여 웹 서버에 파일 생성, 삭제 및 수정이 가능한 취약점


이라고 설명 되어 있는데... 일단 따지지 말고, 조치하자.


점검 방법은 다음과 같다.


1. 80포트로 텔넷 접속 시도(telnet 1.1.1.1 80)

2. 접속 후 OPTIONS * HTTP/1.0 [엔터 2회] 입력

3. 출력 값에 PUT, DELETE와 같은 불필요한 메소드 활성화 여부 확인

4. PUT 메소드가 활성화된 경우 악성 파일 업로드가 가능한지 확인


* 3번의 화면


위 화면은 다 열려있다는 소리.


검색해보면 apache의 httpd.conf 설정하기, 또는 Web Application의 WEB-INF/web.xml에서 설정하기 등이 있는 듯.


Web Application에서 하는 방법으로는, security-constraint를 추가하란다.


[web.xml]

<web-app ...>

...

<security-constraint>

<web-resource-collection>

<web-resource-name>restricted methods</web-resource-name>

<url-pattern>/*</url-pattern>

<http-method>PUT</http-method>

<http-method>DELETE</http-method>

<http-method>OPTIONS</http-method>

<http-method>TRACE</http-method>

<http-method>COPY</http-method>

<http-method>MOVE</http-method>

</web-resource-collection>

<auth-constraint />

</security-constraint>

</web-app>


과 같이 설정하고 WAS 재기동.


web-resource-name에는 대충 적어주고, url-pattern에는 해당 규칙을 사용할 url의 규칙(예제는 모든 요청), auth-constraint 안 넣어주면 작동 안한다. role-name 설정으로 회피 가능.(http://www.4te.co.kr/572 참조)


으로 왠만하면 끝난다는데, 검색하던 중 Spring Framework를 사용했을 경우 실질적으로는 막혀있지만 HTTP Method가 allow에 뜬다고 한다. 그리고 작성자도 동일한 증상. (자세한 것은 http://duco777.blog.me/220765466402 참조)


결국 위 취약점 점검에서 걸린게 이것 때문일테니, 이것까지 막으려면 <servlet>의 DispatcherServlet 설정 부분의 init-param으로 dispatchOptionsRequest를 추가하라고 한다.


[web.xml]

<web-app ...>

...

<servlet>

    <servlet-name>action</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<init-param>

<param-name>...</param-name>

<param-value>...</param-value>

</init-param>

<init-param>

<param-name>dispatchOptionsRequest</param-name>

<param-value>true</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

...

</web-app>


그러면,


이런 식으로 뜬다. 적용 완료.


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함