LoginSignup
3
2

More than 5 years have passed since last update.

xip.io でIPアドレス部分をワイルドカードにしつつDNSリバインディングにも気をつける

Posted at

この例では example.net を自分管理の信頼できるドメイン、example.com を信頼出来ない他人のドメインとして例を書いています。


xip.io を独自のドメインで使っているとき、VirtualHost とかで、

<VirtualHost *>
    ServerName oreore.192.0.2.123.xip.example.net
    (snip)
</VirtualHost>

みたいに長ったらしい名前を書いてしまうと次のような問題があります。

  • なんかキモい
  • IPアドレス変わった時に設定ファイルを弄る必要があって面倒
  • Vagrant box とかに含めて配布するときに不都合

次のようにすれば大丈夫ですが、

<VirtualHost *>
    ServerName oreore.xip.example.net
    ServerAlias oreore.*
    (snip)
</VirtualHost>

これだと、

oreore.evil.example.com.  IN  A  192.0.2.123

みたいなのに反応してしまうので、DNSリバインディング攻撃に対して脆弱です。


次のように ServerAlias で信頼できるドメインを指定して、中間だけをワイルドカードにします。

<VirtualHost *>
    ServerName oreore.xip.example.net
    ServerAlias oreore.*.xip.example.net
    (snip)
</VirtualHost>

これなら、

oreore.evil.example.com.  IN  A  192.0.2.123

みたいなのには反応しないし、.example.net が信頼できるドメインなら安心です。


3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2