ホームページ  >  記事  >  ウェブフロントエンド  >  不審なメンテナがnpmサプライチェーン攻撃のスレッドを暴露

不審なメンテナがnpmサプライチェーン攻撃のスレッドを暴露

WBOY
WBOYオリジナル
2024-07-18 15:06:49365ブラウズ

この物語は、React ベースのオープンソース ドキュメント プロジェクトである Docusaurus のメンテナである Sébastien Lorber が、パッケージ マニフェストに対するプル リクエストの変更に気づいたときに始まります。人気の cliui npm パッケージに提案された変更は次のとおりです:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
具体的には、見慣れない構文を使用する npm 依存関係の変更に注意を向けます:

  "dependencies": {
    "string-width": "^5.1.2",
    "string-width-cjs": "npm:string-width@^4.2.0",
    "strip-ansi": "^7.0.1",
    "strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
    "wrap-ansi": "^8.1.0",
    "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"

ほとんどの開発者は、パッケージの値、またはおそらく Git またはファイルベースの URL に semver バージョンの範囲が含まれることを期待するでしょう。ただし、この場合は、特別な npm: プレフィックス構文があります。それはどういう意味ですか?

このプル リクエストで提案されている変更の場合、パッケージ string-width-cjs はバージョン ^4.2.0 のパッケージ string-width に解決されます。これは、string-width-cjs の node_modules ディレクトリ エントリが存在することを意味しますが、ロックファイル (package-lock.json) には string-width@^4.2.0 の内容と同様の動作が含まれます。

パッケージのエイリアシングは npm パッケージ マネージャーの機能であり、ここでヒントが示されているような場合に正当に使用できます (ESM と CJS のサポートを支援するため)。

そうは言っても、パッケージのエイリアスが悪用される可能性があります。 2021 年に遡る記事とセキュリティ開示の中で、Snyk アンバサダーである Nishant Jain は、依存関係の混乱とサプライ チェーンのセキュリティ上の懸念の一環として、公式の npmjs レジストリがどのように騙されてパッケージのエイリアスに基づいて依存関係情報を誤って知らせる可能性があるかを実証しました。

このプル リクエストは確かに無害であり、サプライ チェーン攻撃のリスクはありません。 しかし、Sébastien はそのようなパッケージ名に疑問を抱きました、さらに心配すべき点があることがわかりました。

npm lockfile で悪意のあるモジュールに関する不審な動作を見つける

Sébastien がプル リクエストを調べたとき、lockfile-lint と呼ばれるツールを実行しました。このツールは、package-lock.json やyarn.lock などのロックファイルを検証して、悪意のあるパッケージを挿入するために改ざんされていないことを確認するのに役立ちます。オリジナルの npm パッケージ。

ツールを実行すると次の警告が表示されました:

npx lockfile-lint --path package-lock.json --allowed-hosts yarn npm --validate-https --validate-package-names

detected resolved URL for package with a different name: string-width-cjs
    expected: string-width-cjs
    actual: string-width

detected resolved URL for package with a different name: strip-ansi-cjs
    expected: strip-ansi-cjs
    actual: strip-ansi

detected resolved URL for package with a different name: wrap-ansi-cjs
    expected: wrap-ansi-cjs
    actual: wrap-ansi

 ✖ Error: security issues detected!

免責事項: lockfile-lint は、ロックファイルのセキュリティ上の懸念を明らかにした私の出版物を受けて 2019 年に開発したツールです。 npm ロックファイルが悪意のあるモジュールを挿入するセキュリティの盲点になる理由.

厳重警戒: npm 上の人気の類似パッケージ

上記の lockfile-lint の結果を考慮して、Sébastien は npm でこれらのパッケージ名を検索し、驚くべきことに、これらがパブリック npm レジストリに存在することを発見しました。

  • https://www.npmjs.com/package/string-width-cjs
  • https://www.npmjs.com/package/strip-ansi-cjs
  • https://www.npmjs.com/package/wrap-ansi-cjs

Sébastien は、これらのパッケージ名が npm に存在するだけでなく、懸念を引き起こす指標があると指摘しました。

  • これらのパッケージは、公開ソース コード リポジトリに関連付けられていません
  • 内容を検査した場合、これらのパッケージには実際のコードは含まれていません。
  • これらのパッケージを公開した作成者の身元は匿名であり、個人情報や特定可能な情報とは関連付けられていません。

npm パッケージのstrip-ansi-cjs を見ると、このパッケージに関連付けられた README やソース コード リポジトリはありませんが、同じ動作を引用している正規の人気パッケージが多数あります。

実際、この特定のパッケージには、多くの依存パッケージ (このパッケージに依存する他のパッケージ) の形で人気の兆候があります。正確には 529 の依存パッケージがあり、毎週のダウンロード数も増加しており、合計で 7,274 です。執筆時間

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
trip-ansi-cjs のコードを見ると、このパッケージにはパッケージ マニフェスト package.json ファイルというファイルが 1 つだけあることがわかります。

それでは、なぜ何もしないパッケージがこれほど多くのダウンロードを獲得し、他の多くのパッケージがそのパッケージに依存するのでしょうか?

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack

これらの npm パッケージの作成者を引き続き調べてみましょう。

3 つのパッケージはすべて hismanshutester002 が所有しており、それらのパッケージはすべてプログラムのバージョン番号とともに昨年公開されました。注目すべき興味深いものもあります:

  • isaacs-cliui npm package - potentially a typosquatting attempt on Isaac’s own fork of the cliui project and the legitimate npm package under their namespace: @isaacs/cliui.
  • azure-sdk-for-net npm package - potentially an attempt at dependency confusion campaign to attack private packages of the same name.
  • link-deep npm package - squatting on a popular capability related to utility packages such as lodash and others

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
You can also note that the user himanshutester002 has no identifiable information on this user profile page on npmjs.

We previously noted that the strip-ansi-cjs npm package has over 500 other packages that use it, therefore, potentially a positive indicator for popularity. Let’s look at them:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
If you give it a glance, this might transfer some sort of legitimacy with this list, but is it?
For example, names like clazz-transformer or react-native-multiply or maybe gh-monoproject-cli seem legitimate, but are they?

Here is the react-native-multiply npm package page:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
This package has virtually no downloads and its author is also an anonymous npm user with no identifiable information. The source URL repository this package redirects to is https://github[.]com/hasandader/react-native-multiply which doesn’t exist and the GitHub user profile looks very suspicious and lacks practical activity.

The npm package contents might seem like there’s some actual source code in there, but in reality, it looks like a generated code sample for a “hello world” application prototype.

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
You also have to wonder, if this package is just a multiplication library, then why does it need 776 dependencies to do the following:

import { multiply } from 'react-native-multiply';
const result = await multiply(3, 7);

While some may mock JavaScript for its abuse of dependencies, contributing to an astronomical tree of nested packages, it doesn’t make any sense for a project to declare 776 direct (top-level) dependencies.

Among all of these dependencies, are the 3 suspicious npm packages that our story began with: string-width-cjs, strip-ansi-cjs, and wrap-ansi-cjs:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
We mentioned that one of the strip-ansi-cjs dependencies was named clazz-transformer. Let’s look at it:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
Let’s explain what is happening here:

  • The npm package name is clazz-transformer, yet the package has a title of class-transformer at the top of the README’s package page here which was purposely done.
  • Similarly, the source code repository is https://github[.]com/typestack/class-transformer which might be a legitimate repository or a fake one, but it is not associating itself at all with the wording “clazz”.

The associated repository’s typstack/class-transformer on GitHub has the package.json file as  follows:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
Looking at the package.json file on GitHub shows no declaration of dependencies, yet if we inspect the source code of the actual package on npmjs we see the 437 dependencies that this clazz-transformer is packaged with. Again, very conveniently bundling the 3 suspicious *-cjs packages:

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack

Further thoughts on suspicious npm package findings

Before we draw further conclusions, it is important to mention a few of the traits of the npm packages we observed above:

  • React Native パッケージは、create-react-native-library スキャフォールド ツールから派生しているようです。このツールには、新しいプロジェクト用に生成されたストック ソース コードの一部として、デフォルトの乗算関数の例も含まれています。
  • パッケージには、npx create-next-app@14 で作成されたものなど、Next.js 14 スターター ボイラープレートから派生できるディレクトリとファイルの構造と依存関係が含まれています。

Sonatype の同僚は、オープンソース レジストリにパッケージが大量に送信される同様のケースを以前に特定しました。このような場合、最終的な目標は、開発者がオープンソース ソフトウェアを収益化するための Web3 プラットフォームである Tea トークンで自分自身に報酬を与えることでした。

言及されたパッケージ内でいくつかの tea.yaml ファイルが見つかると、このキャンペーンの目的の一部が Tea の悪用を通じて Tea トークンをマイニングすることであるという説がさらに裏付けられます。

今年初め、2024 年 4 月 14 日に、Tea フォーラムのユーザーが、Tea 乱用の懸念をさらに裏付けるコメントを投稿しました。

Suspicious Maintainer Unveils Threads of npm Supply Chain Attack
最終的な考えを述べる前に、保守管理者の慎重な考え方と、潜在的な npm サプライ チェーン攻撃のスレッドを明らかにするのに協力してくれた Sébastien Lorber に心から感謝したいと思います。

string-width-cjs では何が起こっているのでしょうか?

現時点では、string-width-cjs に依存していると思われる残りのパッケージに穴を開け続けて、本物の正当性を示す非常に疑わしい指標を見つけることができるという高い自信があります。

これらすべての依存パッケージとダウンロードブーストは、3 つの *-cjs パッケージに偽りの正当性を作成するという唯一の目的につながり、やがて適切な被害者がこれらの偽パッケージを攻撃することになるというのが私の推測です。がインストールされ、続いて新しい悪意のあるバージョンがインストールされます。

オープンソース ソフトウェアを使用する際の安全性を確保するために、セキュリティの実践、特に次のフォローアップ教育リソースを導入することを強くお勧めします。

  • なぜ npm ロックファイルが悪意のあるモジュールを挿入するセキュリティの盲点になるのか
  • 10 npm セキュリティのベスト プラクティス
  • NPM セキュリティ: サプライ チェーン攻撃の防止

私たちは彼らの不正行為の最中にサプライチェーンセキュリティキャンペーンを発見したのでしょうか、それともこれはすべて資金追跡に関するものであり、スパムや、Teaトークンを採掘するためのnpmやGitHubなどのパブリックレジストリの悪用に起因する可能性がありますか?

どのような展開であっても、引き続き警戒してください。

以上が不審なメンテナがnpmサプライチェーン攻撃のスレッドを暴露の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。