최근 DNS reflection을 이용한 DDOS

Arcy의 이미지

한 열흘 전부터 네임서버에 다음과 같은 로그가 쌓이는 것을 볼 수 있었습니다.

Jan 17 02:57:14 y named[4791]: client 216.240.131.173#26201: query (cache) './NS/IN' denied
Jan 17 02:57:16 y named[4791]: client 216.240.131.173#34568: query (cache) './NS/IN' denied
Jan 17 02:57:18 y named[4791]: client 216.240.131.173#19172: query (cache) './NS/IN' denied
Jan 17 02:57:20 y named[4791]: client 216.240.131.173#50197: query (cache) './NS/IN' denied
Jan 17 02:57:22 y named[4791]: client 216.240.131.173#27813: query (cache) './NS/IN' denied
Jan 17 02:57:24 y named[4791]: client 216.240.131.173#9735: query (cache) './NS/IN' denied
Jan 17 02:57:26 y named[4791]: client 216.240.131.173#52903: query (cache) './NS/IN' denied
Jan 17 02:57:28 y named[4791]: client 216.240.131.173#61108: query (cache) './NS/IN' denied
Jan 17 02:57:30 y named[4791]: client 216.240.131.173#4586: query (cache) './NS/IN' denied

그냥 . 쿼리 날리는 멍청한 클라이언트인가보다 하고 iptables로 하나씩 막고 있었는데, 한 번 구글을 검색해보니 DNS reflection spoof DDOS attack이군요.

사실, 저 216.240.131.173이 victim입니다. 발신지는 다른데 source ip를 spoofing해서 victim IP로 보내는거죠. 저 로그에 따르면 제 서버는 ./NS/IN query를 거부하지만, 그렇지 않은 서버라면 13개의 root server리스트를 저 victim에게 보내게 됩니다 (msg size만 228byte). 공격자는 세계 각지의 네임서버를 사용하여 victim을 공격할 수 있는겁니다.

victim입장에선 src port 53인 트래픽을 전부 막을 수 있지만, 그렇다면 외부 DNS에 대해 query하기 힘들죠. 안전한 전용 cache DNS를 마련해야 할 겁니다. 트래픽 측면에서도, ISP에서는 공격이 증폭되어 들어오는 네임서버들을 막을 수는 없습니다. 그렇다면 해당 도메인을 접근할 수 없으니까요.

뭐 victim에 대해서는 애도..할 수밖에 없고.. DDOS 공격이 진화하고 있다고 볼 수밖에 없군요.

일단 제 서버는 제 도메인에 대해 authorized server이기 때문에, bind를 내릴 수도, query를 막을 수도 없습니다. 하지만 . 에 대한 recursive query는 막혀있어 피해가 크지 않습니다. 어쨌든 로그 남는게 귀찮기 때문에 다음과 같은 iptables 룰을 추가합니다.

iptables -I INPUT -p udp --dport 53 -m length --length 45:45 -j DROP

공격하는 패킷 사이즈에 맞추어 DROP 하는 룰입니다. 하지만 공격 패턴을 변화시킨다면 걸러내지 못 할 수도 있습니다. cache DNS라면 이 룰을 추가해서는 안됩니다.

다음 규칙은 쿼리 빈도에 따라 방어합니다.

iptables -I INPUT -p udp --dport 53 -i eth0 -s ! 165.132.0.0/16 -m state --state NEW -m recent --set
iptables -I INPUT -p udp  --dport 53 -i eth0 -s ! 165.132.0.0/16 -m state --state NEW -m recent --update --seconds 60 --hitcount 20 -j DROP

참고 URL:
http://isc.sans.org/diary.html?storyid=5713
https://lists.isc.org/pipermail/bind-users/2009-January/074630.html

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.