間違いだらけの備忘録

このページの内容は無保証でありこのページの内容によって直接、または間接に損害を受けられたとしても私は責任を取りません。

Ken Thompsonの(loginへの)トロイの木馬の現代(open-ssh)版

security.sios.jp

xzのtarボールで、アップストリームバージョンの5.6.0以降に悪意のあるコードが混入されていることがわかりました。liblzmaビルドプロセスにおいて複雑な難読化を用いてソースコード内の偽装テストファイルからビルド済みオブジェクトファイルを抽出します。このファイルは、liblzmaコード内の特定の関数を変更するために使用されます。

難読化してテストで入れ込むの手が込んでるな。
そして良く見付けたなという感でじっくり見ていったら。

postgresqlのmicro-benchmarkしてたところ, username間違えてログインしてるのにsshdがCPU使いすぎだな?ということで気がついたみたい…

なんだと?
mastodon.social

Saw sshd processes were using a surprising amount of CPU, despite immediately failing because of wrong usernames etc. Profiled sshd, showing lots of cpu time in liblzma, with perf unable to attribute it to a symbol. Got suspicious.

oss-security - backdoor in upstream xz/liblzma leading to ssh server compromise

== Impact on sshd ==

The prior section explains that RSA_public_decrypt@....plt was redirected to
point into the backdoor code.

RSA_public_decryptだと?

最後まで読んだら,openssh で情報を拾い上げるだけじゃなくて,RSA_public_decrypt をすげ替えて不正アクセスを受け付けるような事やってるくさいのか・・・

これはひどい

The files containing the bulk of the exploit are in an obfuscated form in
tests/files/bad-3-corrupt_lzma2.xz
tests/files/good-large_compressed.lzma
committed upstream. They were initially added in
https://github.com/tukaani-project/xz/commit/cf44e4b7f5dfdbf8c78aef377c10f71e274f63c0

Note that the files were not even used for any "tests" in 5.6.0.


Subsequently the injected code (more about that below) caused valgrind errors
and crashes in some configurations, due the stack layout differing from what
the backdoor was expecting. These issues were attempted to be worked around
in 5.6.1:

https://github.com/tukaani-project/xz/commit/e5faaebbcf02ea880cfc56edc702d4f7298788ad
https://github.com/tukaani-project/xz/commit/72d2933bfae514e0dbb123488e9f1eb7cf64175f
https://github.com/tukaani-project/xz/commit/82ecc538193b380a21622aea02b0ba078e7ade92

For which the exploit code was then adjusted:
https://github.com/tukaani-project/xz/commit/6e636819e8f070330d835fce46289a3ff72a7b89

Given the activity over several weeks, the committer is either directly
involved or there was some quite severe compromise of their
system. Unfortunately the latter looks like the less likely explanation, given
they communicated on various lists about the "fixes" mentioned above.

https://github.com/tukaani-project/xz
の公式が無効化されていたので、適当に該当ハッシュのあるものを
https://git.rootprojects.org/root/xz.git

$ git show -s --pretty=%an cf44e4b7f5dfdbf8c78aef377c10f71e274f63c0 6e636819e8f070330d835fce46289a3ff72a7b89 72d2933bfae514e0dbb123488e9f1eb7cf64175f 82ecc538193b380a21622aea02b0ba078e7ade92 | cat
Jia Tan
Jia Tan
Jia Tan
Jia Tan

ソーシャル(ハック)時系列
t.co

In April 2022, Jia Tan submits a patch via a mailing list. The patch is irrelevant, but the events that follow are. A new persona – Jigar Kumar enters, and begins pressuring for this patch to be merged.

Soon after, Jigar Kumar begins pressuring Lasse Collin to add another maintainer to XZ. In the fallout, we learn a little bit about mental health in open source.

Three days after the emails pressuring Lasse Collin to add another maintainer, JiaT75 makes their first commit to xz: Tests: Created tests for hardware functions.. Since this commit, they become a regular contributor to xz (they are currently the second most active). It’s unclear exactly when they became trusted in this repository.

Jigar Kumar is never seen again. Another account — Dennis Ens also participates in pressure, with a similar name+number formatted email. This account is also never seen again, and both do not have any associated accounts that have been discovered.
(参考訳)
2022 年 4 月に、Jia Tan はメーリング リスト経由でパッチを送信します。パッチは無関係ですが、その後のイベントは無関係です。新しいペルソナ – Jigar Kumarが登場し、このパッチを統合するよう圧力をかけ始めます。

その直後、Jigar Kumar は XZ に別のメンテナーを追加するようLasse Collin に圧力をかけ始めました。その影響で、私たちはオープンソースにおけるメンタルヘルスについて少し学びました。

ラッセ・コリンに別のメンテナを追加するよう圧力をかける電子メールの 3 日後、JiaT75 は xz に最初のコミットを行いました。テスト: ハードウェア機能のテストを作成しました。。このコミット以来、彼らは xz への定期的な寄稿者になりました (現在、2 番目にアクティブです)。彼らがいつこのリポジトリで信頼されるようになったのかは正確には不明です。

Jigar Kumarは二度と見られない。別のアカウント — Dennis Ensも同様の名前 + 番号形式のメールで圧力に参加しています。このアカウントも再び表示されることはなく、どちらも発見された関連アカウントはありません。

同様のソーシャルハックが繰り返されている。

これで入れ子構造だったら素敵過ぎる。

影響を受けたディストリビューションとその期間が興味ある人へのまとめ。
https://thehackernews.com/2024/03/urgent-secret-backdoor-found-in-xz.html

技術的なまとめ
https://gynvael.coldwind.pl/?lang=en&id=782

このページにはhatena以外のサービスからのコンテンツが埋め込まれています。 hatenaによりGoogle AdSense 広告が埋め込まれています。