Rails 4.2.11.1, 5.0.7.2, 5.1.6.2, 5.2.2.1, and 6.0.0.beta3 have been released!
2019年3月13日 01:49に、Ruby on Rails開発チームからRails現行全バージョンに対してのマイナーアップデートがありました。重大なセキュリティ修正です。すでに目を通した方も多いと思いますが、まだ知らない方もいるようなので、こちらにてまとめます。
今回は現行全バージョンに対して2つの重大な脆弱性(important vulnerability)が発見されており、その改修が行われている模様です。開発チームから早急にupgradeあるいはworkaround(応急処置)をするようにと通告されています。
読むべき人
- RoRを業務で使用している開発者
- 掲題の件について初耳だった人
- 英語がニガテなROR開発者
1.File Content Disclosure in Action View
There is a possible file content disclosure vulnerability in Action View.
Specially crafted accept headers in combination with calls to `render file:`
can cause arbitrary files on the target server to be rendered, disclosing the
file contents.
(訳)Fileコンテンツの漏洩脆弱性の可能性がActionViewにあります。特殊に細工されたaccept header と render fileの組み合わせによって、サーバーに任意のファイルをrenderさせてファイルの漏洩を引き起こすことができてしまいます。
概要
render file: "xxxx/xxxx/xxxx"
上記のようなコードがある場合、そこにある細工をしたaccept headerを送ると、任意のファイルをrenderさせることができてしまいます。
説明が若干足りないですが、.rbとか.ymlとかもrenderできてしまうという認識であっていそう。かなりまずそうです(・ω・;) 開発チームはupgrade or workarounds immediatelyといっています。
対策
以下のいずれかのバージョンにupgradeしましょう。
4.2.11.1, 5.0.7.2, 5.1.6.2, 5.2.2.1, and 6.0.0.beta3
Workaround(すぐにupgradeできない人向け)
Format指定しましょう。これで少なくともhtml以外は任意renderできなくなり、脆弱性は緩和されます。
class XxxContoller
def index
render file: "xxxx/xxxx/xxxx", formats: [:html]
end
end
2. Denial of Service Vulnerability in Action View
Specially crafted accept headers can cause the Action View template location
code to consume 100% CPU, causing the server unable to process requests. This
impacts all Rails applications that render views.
(訳)特殊に細工をされたaccept headerによって"ActionView template location code(=render)"にCPUを100%消費させることを引き起こすことができてしまいます。これによりサーバーはリクエストを処理できなくさせられてしまいます。これはRailsアプリケーションの全てのrenderが対象です。
概要
render "xxxx/xxxx/xxxx"
影響範囲が大きく、全てのrenderが対象です。
細工をされたheaderにより、ActionViewにCPUを100%消費させて、サーバーを停止させるという何ともFunkyな攻撃ができてしまうようです。\(^o^)/ナンテコッタイ
対策
以下のいずれかのバージョンにupgradeしましょう。
4.2.11.1, 5.0.7.2, 5.1.6.2, 5.2.2.1, and 6.0.0.beta3
Workaround(応急処置。すぐにupgradeできない人向け)
class XxxController
def index
respond_to |format|
format.html { render: "index" }
end
end
end
全てのrenderを上記のようにrespond_toとformat指定をすると脆弱性はなくなるようです。
(正直全部のrender直してテストするより、upgradeした方が楽そうですが)
終わりに
技術的、翻訳的に間違っている部分があれば、コメント or 修正リクエストをお願いします。