LoginSignup
2
2

More than 5 years have passed since last update.

bash-3.2 のパッチ for Mac OS X

Last updated at Posted at 2015-01-17

こんにちは。
現時点(2015-01-17)で、Mac OS X で提供されている bash のパッチレベルは 3.2.53 と低いようです(参考:OS X bash Update 1.0 (2014-09-29))。

bash-3.2 についてはパッチレベルはすでに 57 まで出ており(出た日は 2014-10-05)、脆弱性状況は下記のように改善されています。

- CVE-2014-6271  ✔
- CVE-2014-7169  ✔
- CVE-2014-7186  ✔
- CVE-2014-7187  ?
- CVE-2014-6277  ✔
- CVE-2014-6278  ✔

この bash-3.2 のパッチレベルを、Apple 社の提供(?)を待てずに、上げたい人向けの方法を書きました。シェルスクリプトで動かすコマンドを homebrew の formula に仕立てただけですが。

これを動かしたあとの確認は下記のようになるはずで、その後は、現状のコマンド本体の /bin/bash と /bin/sh とを、バックアップを取っておき、ワークディレクトリ内から sudo cp で置き換えれば良いでしょう。

$ cat ~/bash32-fix/bashcheck.out.txt
Testing ~/bash32-fix/bash ...
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin13)

Not vulnerable to CVE-2014-6271 (original shellshock)
Not vulnerable to CVE-2014-7169 (taviso bug)
Not vulnerable to CVE-2014-7186 (redir_stack bug)
Test for CVE-2014-7187 not reliable without address sanitizer
Not vulnerable to CVE-2014-6277 (lcamtuf bug #1)
Not vulnerable to CVE-2014-6278 (lcamtuf bug #2)
Variable function parser inactive, likely safe from unknown parser bugs

以降がパッチを当てるための定義(homebrew の formula)です。

require 'formula'

class Bash32 < Formula
  homepage 'https://opensource.apple.com/tarballs/bash'
  version 'latest'
  sha1 'c833cdc86aab36bbe5f23911a7bcca0e12f905a5'
  url 'https://opensource.apple.com/tarballs/bash/bash-94.1.2.tar.gz'  # 3.2.53

  def install
    # patch-level: 54 55 56 57
    system 'cd bash-3.2; for i in $(seq -f "%03g" 54 57);do curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-$i | patch -p0; done; cd ..'

    system 'xcodebuild'

    workdir = '~/bash32-fix'  # ワークディレクトリ
    outtxt  = 'bashcheck.out.txt'  # 脆弱性確認結果

    system "mkdir #{workdir}"
    system "cp build/Release/bash #{workdir}"
    system "cp build/Release/sh #{workdir}"

    # 脆弱性確認
    system 'curl -O https://raw.githubusercontent.com/hannob/bashcheck/master/bashcheck'
    system "sh bashcheck #{workdir}/bash > #{workdir}/#{outtxt}"
  end
end
2
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
2
2