LoginSignup
179
66

More than 5 years have passed since last update.

Rails4/5/6に関する重大なSecurityFix / 2019年3月13日 01:49

Last updated at Posted at 2019-03-15

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

Google グループ

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させてファイルの漏洩を引き起こすことができてしまいます。

概要

samp.rb
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できなくなり、脆弱性は緩和されます

xxx_controller.rb
class XxxContoller
  def index
    render file: "xxxx/xxxx/xxxx", formats: [:html]
  end
end

2. Denial of Service Vulnerability in Action View

Google グループ

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が対象です。

概要

samp.rb
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できない人向け)

xxx_controller.rb
class XxxController
  def index
    respond_to |format|
      format.html { render: "index" }
    end
  end
end

全てのrenderを上記のようにrespond_toとformat指定をすると脆弱性はなくなるようです
(正直全部のrender直してテストするより、upgradeした方が楽そうですが)

終わりに

技術的、翻訳的に間違っている部分があれば、コメント or 修正リクエストをお願いします。

179
66
3

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
179
66