9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bash更新メモ(CVE-2014-6271 Bash脆弱性対応)

Last updated at Posted at 2014-09-27

OS Xでbash更新メモ(CVE-2014-6271のbashの脆弱性対応)

Update

アップルから最新(09/29)のセキュリティパッチがリリースしました:
http://support.apple.com/kb/DL1769
※このパッチは CVE-2014-6271CVE-2014-7169 のみ対応、
その他 http://en.wikipedia.org/wiki/Shellshock_(software_bug) は未対応らしい。

今回の問題は、アップルも結構重視していますね、パッチを適用するのは一番お勧めです。

0、経緯

最近人気のbashの脆弱性です。http://seclists.org/oss-sec/2014/q3/649

まず、簡単に脆弱性を確認してみます。

$ x='() { :;}; echo 攻撃されやすい' bash -c 'echo hello'
攻撃されやすい
hello

文字列として定義してる「echo 攻撃されやすい」がシェルプログラムとして実行されるので、危険です。
世界中の開発者のおかげで、新しいbashバージョンがリリースされたので、早速更新しましょう。

1、bashを更新するために、Homebrewがおすすめ

Homebrewが初めての方、まずインストール:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ echo $PATH
/usr/local/bin:・・・最初になっていることを確認

すでにHomebrewがインストールされている方、まずセルフ更新を行う必要があります:

$ brew update

2,bash本体をインストール・更新*1

初めての方、最新のbashをインストール

$ brew install bash

すでにHomebrew経由でbashがインストールされている方、bashを更新

$ brew upgrade bash

3,bashのリンクを確認する

$ which bash
/usr/local/bin/bash
$ ls -l /usr/local/bin/bash
lrwxr-xr-x  1 xx  admin  38  9 27 22:08 /usr/local/bin/bash -> /usr/local/Cellar/bash/4.3.26/bin/bash

4,shも新しいbashへリンクする

$ which sh
/bin/sh ★古いバージョンのまま、危険です。

$ ln -s /usr/local/bin/bash /usr/local/bin/sh
$ ls -l /usr/local/bin/sh
lrwxr-xr-x  1 xx  admin  19  9 27 22:24 /usr/local/bin/sh -> /usr/local/bin/bash

5、ターミナルを再起動し、脆弱性が消えたことを確認する

$ x='() { :;}; echo 攻撃されやすい' bash -c 'echo hello' 
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
hello

以上。

エラーシューティング

*1 多分新しいOS X 10.9のせいで、ステップ2で失敗になりました。

エラー:

You have not agreed to the Xcode license agreements, please run 'xcodebuild -license' 
(for user-level acceptance) or 'sudo xcodebuild -license' (for system-wide acceptance) 
from within a Terminal window to review and agree to the Xcode license agreements.

Warning: You have not agreed to the Xcode license.
Builds will fail! Agree to the license by opening Xcode.app or running:
    xcodebuild -license

対策:

$ sudo xcodebuild -license
・・・スペースキーで最後まで移動し、「agree」を入力する必要があります・・・
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel
] agree
9
9
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
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?