LoginSignup
11
11

More than 5 years have passed since last update.

.git/config をゆるく書き換えられてみる

Last updated at Posted at 2014-12-19

git関連でこんなニュースがでていました
http://article.gmane.org/gmane.linux.kernel/1853266
https://github.com/blog/1938-vulnerability-announced-update-your-git-clients

.git/config が書き換えられる脆弱性とのこと。

ということで、実際に書き換えられる雰囲気を感じてみました。(あくまで雰囲気です)

手順

  • テスト用のリポジトリを作る
    • git init
  • 大文字、小文字を区別するファイルシステムを使っているOS上(ubuntuとか)で .Gitフォルダを作り、その中に下記のような`config'ファイルを作る
[user]
    name = changed
    email = changed@
  • commit して 適当な リポジトリにpush する(github等には脆弱性対策のため、問題がありそうなリポジトリはpushできないかもしれないので、自分で管理している場所にpushする)
  • 大文字小文字を区別しないファイルシステムを使っているOS上(windowsとか)で、そのリポジトリを clone する
  • なんかエラーがでるので言われたとおりのコマンドを実行する
Cloning into '.'...
done.
error: Untracked working tree file '.Git/config' would be overwritten by merge.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
  • git checkout -f HEAD
  • .git/config の中身が .Git/config で書き換えられた \(^o^)/

まとめ

  • 言われたとおりにコマンドを実行したら書き換えられた・・・
  • 実際に予想される攻撃方法では clone した段階でスクリプトを実行させることができるので、git のアップデートをしよう
11
11
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
11
11