stMind

about Tech, Computer vision and Machine learning

OSX MavericksでBashのShellshock対策をした

Apple曰く、OS Xのユーザのほとんどはbashの悪用に対して安全 - TechCrunch

確かに、自分もMacをサーバにして公開しているわけではないので、この脆弱性でリモートから攻撃される可能性は低いんですけどね。とはいえ危険が存在しているBashをそのまま使うのは良くないということで、パッチを適用する作業をしました。

パッチ適用手順は、TechCrunchのリンクからたどったページに有りました。

security - How do I recompile Bash to avoid Shellshock (the remote exploit CVE-2014-6271 and CVE-2014-7169)? - Ask Different

$ # If you want to disable auto-imported functions, uncomment the following
$ # export ADD_IMPORT_FUNCTIONS_PATCH=YES
$ 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    
$ curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-053 | patch -p0  
$ # See note above about ADD_IMPORT_FUNCTIONS_PATCH
$ [ "$ADD_IMPORT_FUNCTIONS_PATCH" == "YES" ] && curl http://alblue.bandlem.com/import_functions.patch | patch -p0
$ cd ..
$ # Note: DO NOT ADD SUDO TO XCODEBUILD HERE
$ xcodebuild
$ build/Release/bash --version # GNU bash, version 3.2.53(1)-release
$ build/Release/sh --version   # GNU bash, version 3.2.53(1)-release
$ sudo cp /bin/bash /bin/bash.old
$ sudo cp /bin/sh /bin/sh.old
$ sudo cp build/Release/bash /bin
$ sudo cp build/Release/sh /bin

無事、パッチ適用を確認できました。

(^_^)[23:56:44 satojkovic@stMacBookPro ~]
$ /bin/bash --version
GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.
(^_^)[23:57:27 satojkovic@stMacBookPro ~]
$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
bash: 警告: x: ignoring function definition attempt
bash: `x' の関数定義をインポート中にエラーが発生しました
this is a test