OXY NOTES

NTPを利用したNTPリフレクション攻撃の概略と対策

2014年初頭に欧州で400GBpsという史上最大規模のDDoS攻撃を観測

攻撃手法はntpdのmonlistという機能を利用したDDoS攻撃でした。

わりと最近のことなのでご覧になった方もいると思いますが、JPCERTより「ntpd の monlist 機能を使った DDoS 攻撃に関する注意喚起」という発表がされています。

対岸の火事ではなく、日本でも実際にSmp攻撃の踏み台に利用されたという声も聞くようになりました。設定ファイルに1行追加するだけで対策できるので、ぜひ対策しましょう。


NTPリフレクション攻撃の概略と対策

攻撃者はntpdのmonlistという機能を悪用してDDoS攻撃を行います。monlistとはntpdの状態をリモートで管理するための機能です。

以下のイラストにあるように、問い合わせに対して応答が多いのが特徴です。

cloudflare.comより

実際に問い合わせと応答を実験した方の情報

192byteに対して17160byteの応答をしたそうです。つまり約90倍に増幅されたことになります。理論的には200倍にまで増幅されることがあるため、増幅幅が40倍程度のDNS Amp攻撃よりも高効率です。

NTPリフレクション攻撃対策

試しに以下のコマンドで確かめてみてください。

# ntpdc -c monlist

以下の様な表示なら問い合わせに応答しています。

remote address          port local address      count m ver rstr avgint  lstint
===============================================================================
ntp-b3.nict.go.jp        123 153.122.40.105         1 4 4    1d0      0       0
ntp-a3.nict.go.jp        123 153.122.40.105         2 4 4    1d0      1       0
ntp-a2.nict.go.jp        123 153.122.40.105         1 4 4    1d0      1       1

応答していない場合は以下の様な表示になります。

***Server reports data not found

NTPの設定ファイルを編集します

# vi /etc/ntp.conf

以下の設定がコメントアウトされていないか確認する

実はRHLEやCentOSの場合はデフォルトで以下設定になっています。これはipv4、ipv6共に全てのアクセスを拒否しています。
この後に続いて許可したホストに対して特定の機能を許可するという流れになります。

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

NICT公開NTPサービスを利用する

以下のようにcentosのデフォルトの設定の場合はntp.nict.jpのものを利用させていただきましょう。ISPで別途NTPサーバを提供している場合はそちらを利用しましょう。

server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
↓
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
server -4 ntp.nict.jp iburst
server -4 ntp.nict.jp iburst
server -4 ntp.nict.jp iburst

最終行に追加

# NTP Dos攻撃対策
disable monitor

NTPの再起動

# /etc/init.d/ntpd restart

NTPが正しく設定できたか確認

# /usr/sbin/ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp-b2.nict.go. .NICT.           1 u   49   64    1   11.338   -5.813   0.192
*ntp-a3.nict.go. .NICT.           1 u   58   64    3    2.674   -2.028   0.174
 ntp-a2.nict.go. .NICT.           1 u   58   64    3   10.498   -6.386   0.218

続いて問い合わせに対して応答しないか確認

# ntpdc -c monlist
***Server reports data not found

これでNTPリフレクション攻撃に対する対策ができました。
しかしよく次から次に新しい攻撃を思いつくなと、逆に関心しますね。