エロサイトの作り方

2013年11月から勉強しながらエロサイトを作っています。

Ubuntu 12.04と14.04でbashの脆弱性(ShellShock)対策をする

やり方はどっちも同じですが、移行途中で両方の環境があったので一応記録として。

対応が必要なバージョン

Update instructions

The problem can be corrected by updating your system to the following package version:

Ubuntu 14.04 LTS: bash 4.3-7ubuntu1.1

Ubuntu 12.04 LTS: bash 4.2-2ubuntu2.2

Ubuntu 10.04 LTS: bash 4.1-2ubuntu3.1

USN-2362-1: Bash vulnerability | Ubuntu

このバージョン未満だと、脆弱性があるみたいです。

(更新前のbashバージョンを確認し忘れたので未確認なのですが、更新後にこのバージョンよりもけっこう進んでいたので直近のバージョンでなくても対応していたのかも?)

apt-getとaptitude

Ubuntuにはパッケージ管理コマンドにapt-getaptitudeがあるんだけど、 違いの解説ページを見ていると基本的にはaptitudeを使い、aptitudeでは解決し難いケースが出たらapt-getを使う、というのが基本みたいです。

まあ初心者はとりあえずaptitudeを使っておけってことですね。

Ubuntu 14.04 LTSの場合

OSバージョン

$ cat /etc/lsb-release
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"

パッケージリストの更新

$ sudo aptitude update
...
Fetched 1,981 kB in 33s (58.7 kB/s)

完了。

bashの更新

$ sudo aptitude upgrade bash
The following packages will be upgraded:
  bash
1 packages upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
Need to get 574 kB of archives. After unpacking 0 B will be used.
Do you want to continue? [Y/n/?]

yで続行。

Get: 1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main bash amd64 4.3-7ubuntu1.3 [574 kB]
Fetched 574 kB in 3s (175 kB/s)
(Reading database ... 79367 files and directories currently installed.)
Preparing to unpack .../bash_4.3-7ubuntu1.3_amd64.deb ...
Unpacking bash (4.3-7ubuntu1.3) over (4.3-7ubuntu1) ...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up bash (4.3-7ubuntu1.3) ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode

Current status: 17 updates [-1].

これで完了。

更新後のbashのバージョン

$ bash --version
bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

脆弱性テスト

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

ちゃんとエラーになってくれた。

Ubuntu 12.04 LTSの場合

OSバージョン

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"

パッケージリストの更新

$ sudo aptitude update
...
Fetched 4,265 kB in 7s (546 kB/s)

完了。

bashの更新

$ sudo aptitude upgrade bash
The following packages will be upgraded:
  bash
1 packages upgraded, 0 newly installed, 0 to remove and 44 not upgraded.
Need to get 641 kB of archives. After unpacking 0 B will be used.
Do you want to continue? [Y/n/?] y

同じくyで続行。

Get: 1 http://archive.ubuntu.com/ubuntu/ precise-updates/main bash amd64 4.2-2ubuntu2.3 [641 kB]
Fetched 641 kB in 2s (229 kB/s)
(Reading database ... 113025 files and directories currently installed.)
Preparing to replace bash 4.2-2ubuntu2.1 (using .../bash_4.2-2ubuntu2.3_amd64.deb) ...
Unpacking replacement bash ...
Processing triggers for man-db ...
Setting up bash (4.2-2ubuntu2.3) ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode.

Current status: 44 updates [-1].

完了。

更新していない他のパッケージが多いですね……

更新後のbashのバージョン

$ bash --version
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

脆弱性テスト

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

こちらもちゃんとエラーになってくれた。