Hash Dos 그것은 무언인가.. 또한 어떤 영향력이 있는지. 알아보자.
- 현재 Hash Dos에 위험에 있는 위험군 프로그램들의 버전부터 알아봅시다.
PHP의 경우 max_input_vars 변수가 추가되었다고 합니다
발생 버전
Java, all versions
JRuby <= 1.6.5
PHP <= 5.3.8, <= 5.4.0RC3
Python, all versions
Rubinius, all versions
Ruby <= 1.8.7-p356
Apache Geronimo, all versions
Apache Tomcat <= 5.5.34, <= 6.0.34, <= 7.0.22
Oracle Glassfish <= 3.1.1
Jetty, all versions
Plone, all versions
Rack <= 1.3.5, <= 1.2.4, <= 1.1.2
V8 JavaScript Engine, all versions
수정된 버전
Java, N/A
JRuby >= 1.6.5.1
PHP >= 5.3.9, >= 5.4.0RC4
Python, N/A
Rubinius, N/A
Ruby >= 1.8.7-p357, 1.9.x
Apache Geronimo, N/A
Apache Tomcat >= 5.5.35, >= 6.0.35, >= 7.0.23
Oracle Glassfish, N/A (Oracle reports that the issue is fixed in the main codeline and scheduled for a future CPU)
Jetty, N/A
Plone, N/A
Rack >= 1.4.0, >= 1.3.6, >= 1.2.5, >= 1.1.3
V8 JavaScript Engine, N/A
등 버전이 되겠습니다.
현재 매우 위험에 있습니다.
- HashDOS 사건이 어떻게 생겼는지에 대해 알아봅시다.
HashDos라는 신종 DDOS 수법이 미국 시간으로 12월 31일 밤에 있을 것이라는 소식이 있습니다.
(1) 방식
웹 서버에 POST나 GET으로 전송된 변수들은 값 접근을 쉽고 빠르게 하기 위해 Hash 자료 구조를 사용합니다.
(PHP라면 $_GET, $_POST ) 그런데, Hash 구조에서는 동일한 hash값을 갖는 key가 존재하게 되는데
이런 collision이 많게 되면 worst case로 Hashing 관련 insert, lookup 비용이 O(n^2) 씩 걸리게 된다고 합니다.
collision을 발생시키는 key 값들만 POST로 요청을 보내는 방법입니다.
8 MB짜리 데이터를 POST 요청시 288분 동안 CPU를 점유합니다.
?500Kb짜리 POST 요청으로 1분 이상 CPU를 점유합니다.
?300k짜리의 경우 30초 동안 CPU를 점유합니다.
이 내용을 보시면 매우 서버에 위험이 된다고 보입니다.
HashDos대상에는 PHP, ASP.NET, tomcat 모두 해당된다고 합니다 .
뉴스 자료
Large percentage of websites vulnerable to HashDoS denial of service attack
Researchers presented information on a long standing vulnerability in most web application frameworks at today's 28c3 (28th Chaos Communication Congress) security conference in Berlin, Germany, Earth, Milky Way.
Alexander "alech" Klink and Julian "zeri" Wälde delivered a demonstration and lecture titled "Efficient Denial of Service Attacks on Web Application Platforms". In their lecture they explained in detail how most web programming languages utilize hashes and manage collisions.
The type of hashing used by PHP, Java, Python and JavaScript in this attack is not a cryptographic hash, it is a simple mathematical hash used to speed up storing and retrieving data posted to web pages.
Collisions in these hashes are expected and managed by the programming framework in a reliable way when not being abused.
It is known that an attacker who understands the values used in your hashing algorithm could pre-compute a set of values that result in all hashes being the same. Comparing these hashes becomes a quadratic function which can create a very heavy load on the web server.
An example given showed how submitting approximately two megabytes of values that all compute to the same hash causes the web server to do more than 40 billion string comparisons.
During the talk they performed a denial of service attack against an Apache Tomcat server, which is a commonly used java servlet container for hosting web pages.
They sent the server some pre-computed hash collisions and showed how it used 100% of their processor for the entire talk.
They explained that the proper solution to the problem is for the developers of the vulnerable programming languages to randomize the key used when computing hashes. This would prevent an attacker from being able to pre-compute the collisions.
Perl was updated to fix this problem in version 5.8.1, which was released in September of 2003. For some reason most of the other languages did not take the cue from Perl and are still vulnerable to these attacks.
Without fixing the hashing functions in the languages themselves there are three mitigation techniques available to website operators.
- Reduce the length of parameters that can posted.
- Reduce the number of parameters accepted by the web application framework.
- Limit the amount of CPU time that any given thread is allowed to run.
- Microsoft has released an advisory for ASP.NET customers with advice on mitigation until they are able to ship a more permanent fix.
- It may be possible to configure web application firewalls and other network security devices to limit the impact of an attack as well, it would certainly be worth your time to consult with your security vendors to see if they can help.
- Update: Microsoft have released a fix less than 24 hours after disclosure. ASP.NET admins can download patch MS11-100 to protect their IIS web assets. More information is available on the Microsoft SRD blog.
- MS11-100 also fixes three other privately disclosed vulnerabilities, including one which could allow arbitrary code execution and elevation of privilege. Microsoft considers this update as critical, and I concur.
미국 현지 발표 자료 pdf
ASP,PHP,TOMCAT은 매우 취약한 상태입니다.
관련 :
톰캣에 대안 방안
Http request 를 통한 변수 전달 방식에서 변수값 접근을 용이하게 하기 위해서 hash 형태로 변경하여
사용하는 점을 이용한 공격 입니다.
동일한 key 값을 사용하요 collision 발생
get 방식은 length 의 제한이 있어 공격이 어렵고 post 방식으론 시스템에 큰 부담을 줄수 있는데
500kb 정도면 cpu 1분이상을 점유 할수 있다고 합니다.
예방 방법으로는 post로 넘어오는 parameter 갯수를 제한하는게 최선의 방법입니다.
tomcat 의 경우은 maxParametercount 값을 넣어줘야 하는데 6.0.35 이상 / 7.0.23 이상 부터 지원하네요
저희의 경우엔 tomcat을 사용중이어서 tomcat upgrade 및 parameter값 조절로 해결한 상태입니다.
그외에에도 ASP/PHP 에 대한 공격들도 가능하여 관련 자료들을 참고하시면 좋을것 같습니다.
먼저 공격 동영상 한편을 보자.
Denial of Service using Hash tables collisions in PHP
hash table collisions버그를 이용해서 PHP로 DoS공격을 하는 예이다. 동영상에서는 약 190초 동안이나 CPU load가 15%정도 올라갔다. H/W사양이나 요청하는 POST값은 다양하니 수치의 의미보다는 load 상승의 심각성을 중요포인트로 생각해야 한다. 이런 비정상 요청 몇개만으로 서비스는 제대로 이뤄지지 않을 수 있다. '단 몇개만'으로.
웹서버에서는 Request POST, GET 변수를 hash 구조로 관리한다. 그런데 POST 요청 파라미터수가 상당히 많을 경우(GET 요청은 길이 제한이 있으므로 문제가 되지 않음)에 hash 충돌이 많이 발생하게 되어 CPU load가 상당히 올라가게 된다. 이런 문제는 PHP5, Asp.Net, Java, V8 자바스크립트 엔진 등에서 발생한다.
PHP의 경우 5.4.0 RC버전과 앞으로 나올 PHP 5.3.9 버전에서 max_input_vars 설정으로 파라미터 개수를 제한할 수 있다.
현재 @hashDoS 트위터( http://twitter.com/hashDoS )에서 이번 취약점에 대한 논의가 있으니 참고하기 바란다.
* hashDoS 취약점 관련 글
- [SECURITY] Apache Tomcat and the hashtable collision DoS vulnerability
- Denial of Service through hash table multi-collisions http://www.nruns.com/_downloads/advisory28122011.pdf
- Hash collisions vulnerability in web servers
- PHP Hash Table Collision Bug Lets Remote Users Deny Service
-
출처 : http://www.xpressengine.com/20389195
XE 개발자 : 체리필터 (cherryfilter)