LoginSignup
12
12

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-09-25

参考

一括でcgiの1行目を確認する方法

find . -type f -name "*.cgi" -exec head -n 1 {} \; 2>/dev/null

で、/bin/shの実体が/bin/bashの場合、外部からの攻撃を受け兼ねない。

hoge.cgi
#!/bin/sh
echo 'hoge'

bashのアップデート

yum
yum update bash
pacman
pacman -Sy bash

脆弱性のチェック

AHO='() { baka; }; echo manuke' bash -c 'echo Hi'

と入力し、manukeが表示されたら脆弱性の対象。
macosx 10.9.5, centos, archlinuxにて対象を確認。

修正後の動作確認

$ AHO='() { baka; }; echo manuke' bash -c 'echo Hi'
bash: 警告: AHO: ignoring function definition attempt
bash: `AHO' の関数定義をインポート中にエラーが発生しました
Hi

こうでればOK。

レガシーシステムの場合

ls -l /bin/sh

を確認し、/bin/bashでなければOK。
/bin/bashの場合、

apt-get install dash
unlink /bin/sh && ln -s /bin/dash /bin/sh

すればよい。

CentOS4の場合

12
12
2

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
12
12