강좌
클라우드/리눅스에 관한 강좌입니다.
리눅스 분류

TCP SYN FLOOD

작성자 정보

  • 웹관리자 작성
  • 작성일

컨텐츠 정보

본문


TCP SYN FLOOD

최근 두종류의 지하 잡지에 "반만 열린" TCP 연결들을 생성하므로써 서비스거부공격을 하는 코드가 발표되었다. 인터넷에 연결되어 TCP 기반의 서비스(예를 들면, 웹서버, FTP서버, 또는 메일서버 등)를 제공하는 모든 시스템들이 이 공격에 노출되어 있으며, 공격의 결과는 시스템에 따라 다르다. 그러나 이 문제에 대한 완벽한 해결책은 없으며 단지 영향을 감소시키는 방법들만이 알려져 있다.

어떤 시스템(클라이언트)이 서비스를 제공하는 시스템(서버)에 TCP 연결을 시도할 때, 클라이언트와 서버는 다음과 같이 일련의 메시지들을 교환한다. 먼저 클라이언트 시스템은 서버에 SYN 메시지를 보내며, 서버는 SYN-ACK 메시지를 클라이언트에 전송하므로써 접수된 SYN 메시지에 대해 확인한다. 클라이언트는 다시 ACK 메시지를 전송하므로써 접속 설정을 완료한다. 이렇게 하므로써 클라이언트와 서버 사이의 접속이 열리게 되고, 클라이언트와 서버사이에 서비스에 고유한 자료들을 교환할 수 있게된다. 이러한 접속방법은 모든 TCP 연결(텔넷, 전자우편, 웹 등) 에 대해 적용된다.

공격의 가능성은 바로 서버가 클라이언트에 확인 메시지(ACK-SYN)을 보낸 후 클라이언트로 부터 다시 확인 메시지(ACK)를 받기 이전의 시점에서 발생한다. 이 상태가 바로 "반만 열린" 연결이라고 불린다. 서버는 모든 진행중인 연결에 대한 정보를 저장하기 위해 시스템 메모리에 자료구조를 구축하며 이 자료구조는 그 크기가 제한되어 있다. 따라서 계속하여 "반 만 열린" 연결을 생성하므로써 이 자료구조를 넘치게 할 수 있다.

반만 열린 연결은 IP 속이기를 이용하면 손쉽게 생성할 수 있다. 공격자 시스템에서 피공격 서버에 적법하게 보이지만 실제로는 ACK-SYN에 대해 응답할 수 없는 클라이언트를 참조하는 SYN 메시지를 발송한다. 따라서 피공격 서버는 최종 SYN 메시지를 받 을 수 없게된다. 마침내 피공격 서버측의 "반만 열린" 연결을 위한 자료 구조가 가득차게 되고 이 자료 구조가 비워 질 때까지 피공격 서버는 새로운 연결 요구에 대해 응답할 수 없게 된다. 일반적으로 반만 열린 연결에 대해서는 타임아웃 값이 설정되어 있어 일정 시간이 경과하면 자동적으로 취소되게 되므로 새로운 연결에 대해 응답할 수 있게 된다. 그러나 이와같은 복구에 소요되는 시간보다 빠르게 공격자 시스템이 반복적으로 속임용 IP 패킷을 전송할 수 있다.

대부분의 경우, 이러한 공격의 피해 시스템은 새로운 네트워크 연결 요청을 받아 들이는데 곤란을 겪게 되며 서비스제공 능력의 저하를 가져온다. 그러나 기존의 외부로 부터의 연결이나, 외부로의 새로운 접속 요청 전송에는 영향을 받지 않는다. 그러나 특별한 경우, 시스템의 메모리가 고갈되거나, 파괴되거나, 또는 작동불가능하게 될 수도 있다.

SYN 패킷의 근원지 주소가 가짜이므로 공격의 근원을 알아내는 것은 어려우며 패킷이 피공격 서버에 도착한 뒤에 근원을 알아내는 것은 불가능하다. 네트워크는 패킷을 목적지 주소만을 이용하여 전달하므로 근원을 검증하는 유일한 방법은 입력 소스 필터링을 이용하는 것 뿐이다.

현재의 IP 프로토콜 기술로는 IP 속임 패킷을 제거하는 것이 불가능하므로 현재로서는 이 문제에 대한 완전한 해결책이 없는 상태이다. 그러나 관리하고 있는 네트워크로 유입되거나 이로부터 유출되는 IP 속임 패킷을 감소시킬 수 있는 방법이 있다. 즉, 라우터를 적절히 구성하므로써 공격당할 가능성을 줄이거나, 해당 사이트내의 시스템이 공격의 근원이 될 수 있는 가능성을 감 소시킬 수는 있다.

현재로서의 최상의 해결책은 외부 접속용 인터페이스로의 유입을 제한하는 필터링 라우터(입력 필터라고 부름)를 설치하여 근원이 내부 네크워크인 모든 패킷의 유입을 금지시키는 것이다. 이에 더하여 근원이 내부 네트워크가 아닌 모든 패킷의 유출을 금지시켜 관리하의 사이트로 부터 IP 속임 공격이 발생되는 것을 방지할 수 있다. 그러나 이러한 방법도 외부 공격자가 다른 임의의 외부 주소를 이용하거나, 내부의 공격자가 내부의 주소를 이용하여 공격하는 것에 대해서는 방어하지 못한다.


Patches from BSDI Co.

PATCH:

K210-021

SUMMARY:

This patch adds two networking features that can help defeat and detect some types of denial of service attacks.

The first feature is a limit on the number of fragmented IP packets in the IP reassembly queue. The default limit is 200 and can be changed with the sysctl(8) variable "net.inet.ip.maxfragpackets". To change the limit of the n umber of packets on the IP reassembly queue add a command like the following to the end of /etc/netstart. This example would reduce the limit on outstanding fragments to 100:

sysctl -w net.inet.ip.maxfragpackets=100

The second feature is an optional test to insure that packets are received on the expected interface. This feature lo oks up the route back to the source of received IP packets. If there is no route to the source available, or the packet did not arrive on the expected interface the packet is discarded. The expected interface is the one that would be used to send a packet back to the reported source of the packet.

IP source address verification should not be used when concurrent alternate paths exist from the BSD/OS system where t his feature is enabled, as this may cause valid packets to be discarded. For example, a small ISP that has one connecti on to a backbone network and one connection to each of it's clients could enable this feature. If the same ISP has two connections to a backbone network, or one connection to each of two backbone networks they should not enable this featur e.

IP source address verification is an valuable tool for protecting against some forms of IP-spoofing as described in CE RT advisory CA 96.21, "TCP SYN Flooding and IP Spoofing Attacks". The full text of this advisory is available as ftp://info.cert.org/pub/cert_advisories/CA-96.21.tcp_syn_flooding.

If you are a service provider, using IP source verification will protect your customers against attacks from the Inter net which appear to be coming from your customers' networks, and it will ensure that packets sent from your customers' n etworks have a source address on your customers' networks (preventing them from spoofing source addresses and/or attacki ng others).

This feature is enabled via the "net.inet.ip.sourcecheck" sysctl(8) variable or by adding the "IPSOURCE CHECK" option when building a kernel. For example, to enable IP source address verification, add the following com mand to the end of /etc/netstart:

sysctl -w net.inet.ip.sourcecheck=1

The IP source address verification code will log a message when discarding a packet. To prevent a large number of the se packets from using an excessive amount of disk space log messages are limited to one per IP address per time interval . The time interval defaults to five seconds and may be configured with the "net.inet.ip.sourcecheck_logint" sysctl(8) variable. A value of zero disables the time interval.

This patch requires U210-025 which provides new copies of sysctl(8) and netstat(1) for configuration and monitoring of these new features.

===================================================================

PATCH:

K210-022

SUMMARY:

This patch adds a TCP SYN cache which reduces and/or eliminates the effects of SYN-type denial of service attacks such as those discussed in CERT advisory CA 96.21. When a large number of SYN packets arrive for the same TCP port, the old code would drop the excess SYN packets, assuming that they will be retransmitted and that the current 1/2 open connecti ons will soon be completed and removed from the queue.

However, due to one-way and/or long paths, or malicious intent, the queue can become clogged with 1/2 open connections that will never complete, preventing any valid connections from being established.

With the SYN cache, when the accept queue overflows a minimal amount of state is stored in the SYN cache, and a SYN,AC K response is sent. If a valid ACK comes back, a complete connection is created. If there is no route or a TCP RST or ICMP Unreachable comes back, the entry is deleted. Otherwise, the entries will just time out.

There are several new sysctl entries. Note that they should not be changed unless there is evidence that the default values are not adequate.

o net.inet.tcp.syn_cache_limit

This specifies the maximum number of entries that may be held into the SYN cache.

o net.inet.tcp.syn_bucket_limit

This specifies the maximum number of entries that may be held in any individual hash bucket of the SYN cache.

o net.inet.tcp.syn_cache_interval

This specifies in 0.5 second increments, how often the timeout routine for the SYN cache should be run.

The default maximum cache size is 10255, with a hash table size of 293 and a maximum per bucket limit of 105 (10255 = 293*35, 105 = 3*35). If INET_SERVER is defined, the default maximum cache size is 34895, a hash table size of 997, and a per bucket limit of 105 (34895 = 997*35, 105 = 3*35).

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,040 명
  • 현재 강좌수 :  35,850 개
  • 현재 접속자 :  164 명