LoginSignup
97

More than 5 years have passed since last update.

CVE-2014-6271のbashの脆弱性に対応する方法

Last updated at Posted at 2014-09-25

Mac

Macの場合は、HomebrewMacPortでも修正版である4.3.25が配布されています。したがって、以下のコマンドで対応できます。

Homebrew

$ brew update

$ brew upgrade bash

MacPort

$ sudo port self update

$ sudo port upgrade bash

/bin/bash

脆弱性を有しているかどうかは以下のコマンドを実行すると分かります。

$ env x='() { :;}; echo vulnerable' bash -c 'echo hello'
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
hello

デフォルトでインストールされているbashである/bin/bashは、手元環境を確認した所によるとbash 3.2になりました。

$ /bin/bash --version

これを最新版に差し替えるか、パッチを当てておくほうが良いでしょう。

new

ただし、既存のシェルスクリプト等がバージョン間の実装差異の問題で死んでしまう可能性が (わずかですが) あります。注意してください。

$ /usr/local/bin/bash --version
4.3.25

$ mkdir bash-3.2-old

$ sudo cp /bin/bash !$

$ sudo cp -v /usr/local/bin/bash /bin

古いやつ残しておく場合は、念のためchmod a-xした方がいいと思います。

patch

$ mkdir bash-fix

$ cd bash-fix

$ curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf -

$ cd bash-92/bash-3.2

$ curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-052 | patch -p0

$ cd ..

$ xcodebuild

$ sudo cp /bin/bash /bin/bash.old

$ sudo cp /bin/sh /bin/sh.old

$ build/Release/bash --version # GNU bash, version 3.2.52(1)-release

$ build/Release/sh --version   # GNU bash, version 3.2.52(1)-release

$ sudo cp build/Release/bash /bin

$ sudo cp build/Release/sh /bin

$ sudo chmod a-x /bin/bash.old /bin/sh.old

oss-sec: CVE-2014-6271: remote code execution through bash http://seclists.org/oss-sec/2014/q3/649

security - How do I recompile Bash to avoid the remote exploit CVE-2014-6271? - Ask Different http://apple.stackexchange.com/questions/146849/how-do-i-recompile-bash-to-avoid-the-remote-exploit-cve-2014-6271

sh

/bin/shも実質、bashである可能性があります。調べて、問題があるようなら、パッチを当てるかしたbashをリネームしたりしてください。

$ which sh
/bin/sh

$ sh --version

Linux

yum

# yum update bash

# /sbin/ldconfig

pacman

# pacman -Sy bash

参考

bashの脆弱性によりCGIのshebangの実体がbashの場合、任意のコマンド発行できる件 - Qiita

AWS - bash脆弱性への対応 - Qiita

bashの脆弱性(CVE-2014-6271) #ShellShock の関連リンクをまとめてみた - piyolog

追加

ウェブアプリにおけるBash脆弱性の即死条件 #ShellShock - めもおきば

ファイアウォール内のサーバに対するShellshockを利用した攻撃 - 葉っぱ日記

影響範囲はどこまで?:bashにコードインジェクションの脆弱性「Shellshock」、管理者に大きなショック - @IT

0day.jp (ゼロデイ.JP): bash 0dayマルウェア感染の「real time」リバースエンジニアリング

bash の脆弱性 "Shell Shock" のめっちゃ細かい話 (CVE-2014-6721) - もろず blog

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
97