사이트 내 전체검색
php 해쉬 테이블 취약점 (HashDoS) 공격 방어
로빈아빠
https://cmd.kr/server/943 URL이 복사되었습니다.

본문

최종 업데이트 : 2012/01/08

hash table 을 이용한 DOS가 상당히 요즘 화두가 되고 있습니다.
다행히, 한국을 사랑하는 독일인(스테판 에써(Stefan Esser))이 이미 모듈을 제공하고 있습니다.

관련하여, 내용 간단히 정리/테스트하였습니다.

도움되시기 바랍니다.


[관련이슈]
- 해시 테이블 구현 오류로 인해 해당 기능을 사용하는 다양한 응용프로그램 및 서비스를 대상으로
- 시스템 자원을 고갈시켜(CPU) 장애를 유발시킬 수 있는 취약점이 발견됨
- 공격자는 해당 취약점에 영향 받는 시스템에 특수하게 조작된 요청을 전송 할 경우,
- 서비스 거부 상태를 유발시킬 수 있음

[관련뉴스]
http://www.krcert.or.kr/secureNoticeView.do?num=622&seq=-1
http://www.boannews.com/media/view.asp?idx=18416
https://github.com/laruence/laruence.github.com/tree/master/php-5.2-max-input-vars
http://www.php.net/
http://technet.microsoft.com/ko-kr/security/bulletin/ms11-100


[영향 받는 시스템]
① 영향받는 버전
PHP 5.3.8, 5.4.0RC3 및 이전버전

② 패치된 버전
PHP >= 5.3.9, >= 5.4.0RC4


[다운로드] * 공식사이트
http://www.hardened-php.net/suhosin/download.html
http://download.suhosin.org/suhosin-0.9.32.1.tar.gz
http://download.suhosin.org/suhosin-0.9.29.tgz


[다운로드] * 필수 패키지

php-devel (phpize를 위해 필요함)


[다운로드] * rootman
suhosin-0.9.29.tgz (md5sum : e3c599e7e344e981f935b2dab90592c1) 
suhosin-0.9.32.1.tar.gz (md5sum : 26a86f0f684a656c3e789e3eb4ec1db3) 


[root@ns1 suhosin-0.9.29]# phpize && ./configure && make && make install
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20050922
Zend Extension Api No: 220051025
....
...
..

[root@ns1 ~ ]# php -v
PHP 5.1.6 (cli) (built: Nov 29 2010 16:47:37) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH


[php.ini 수정]
; 2012/01/05, chanho
extension=suhosin.so
suhosin.log.file=511
suhosin.log.file.name=/var/log/httpd/suhosin.log
suhosin.post.max_value_length = 1000000 
suhosin.post.max_vars = 100
suhosin.request.max_vars = 100


[웹서버 재가동]
[root@ns1 ~]# /etc/init.d//httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]


[환경파일 설명]
post.max_vars ==> POST method 로 넘겨지는 변수(parameter) 최대 개수
request.max_vars ==> cookie, GET POST로 넘겨지는 변수(parameter) 최대 개수


[별첨] 로그패턴 #1
(1) undefined symbol: zend_atol
- 원인 : apache와 suhosin 모듈 호환성 유형
- 해결
① suhosin.simulation = On // 문서에 나와 있는데 제대로 되지 않음
② suhosin 버전 다운그레이드 (현재 0.9.32.1 --> 0.9.29로 다운로드)


[별첨] 차단 로그(/var/log/suhosin.log) #2
Jan 9 05:07:34 [21421] ALERT-SIMULATION - configured POST variable limit exceeded - dropped variable 'EzFYFYFYEzH.EzFY' (attacker '111.111.111.111', file '/home/host/html/index.html')


[별첨] 설정파일 #3
config 설정 : http://www.hardened-php.net/suhosin/configuration.html#configuration


[별첨] 공격 테스트 #3
- 공격 대수 : 2대
- parameter 개수 : 65,535건
- POST 사이즈 : 1.4M
- 공격방법 : 30~40여분동안 원격지 call
- 시스템 성능 : E5520 @ 2.27 쿼드코어, RAM:6G, (OS : CentOS5.5, http : 2.2.3, PHP : 5.1.6, Kernel : 2.6.18-194.17.1.el5PAE)


[결론] #4
- hash dos를 위해, php 버전 업그레이드가 힘들다면 suhosin 패치 강력 추천함
- 패치 후 iowait이 발생하긴 하지만, 대세에 지장 없음


[TODO] #5
- 모니터링에 /var/log/suhosin.log를 파싱하여 발생 시 sms 통보 혹은 즉각적인 아이피 차단 필요
- php 피치

끝.

댓글목록

등록된 댓글이 없습니다.

1,139 (3/23P)

Search

Copyright © Cmd 명령어 3.143.205.169