【发布时间】:2014-09-14 05:52:26
【问题描述】:
我非常担心我构建的网络应用程序的安全性,因此我一直在使用各种工具来抓取我的每个应用程序。
虽然在编程方面可以完成的所有事情,以及像 Active Record 这样的现成类没有预见到的事情都已经完成,但有一个问题我不断收到警报,我不知道从哪里开始解决这个问题。
我在 Unicorn 后面运行 Nginx 和 Rails 4.1。我不断收到的警报是这样的:
An attacker can manipulate the Host header as seen by the
web application and cause the application to behave in
unexpected ways. Developers often resort to the exceedingly
untrustworthy HTTP Host header (_SERVER["HTTP_HOST"] in PHP).
Even otherwise-secure applications trust this value enough to
write it to the page without HTML-encoding it with code equivalent to:
<link href="https://_SERVER['HOST']" (Joomla)
...and append secret keys and tokens to links containing it:
(Django, Gallery, others)
....and even directly import scripts from it:
(Various)
发出以下建议:
The web application should use the SERVER_NAME instead
of the Host header. It should also create a dummy vhost
that catches all requests with unrecognized Host headers.
This can also be done under Nginx by specifying a non-wildcard
SERVER_NAME, and under Apache by using a non-wildcard serverName
and turning the UseCanonicalName directive on. Consult references
for detailed information.
当然,无论如何.. 据我了解,这种漏洞通常是无害的,但在各种网络应用程序中可能是有害的,具体取决于它们的种类。
我该怎么做才能阻止这种攻击?感谢您的任何建议。
【问题讨论】:
标签: ruby-on-rails security ruby-on-rails-4 nginx