2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

マルウェア「Shai-Hulud」に対する一括セキュリティスキャンツール

Last updated at Posted at 2025-09-18

作成したツール

https://github.com/Blank-Vulture/npm-security-scanner
Shai-Huludの感染状態を一括で確認するGO製CLIツールです。

使い方

プロジェクトをまとめる作業用のディレクトリを作って、その中でプロジェクト毎にサブディレクトリを作って複数のnpmを使用したプロジェクトを管理されている方向けです。

つまり、以下のような構造でプロジェクトを管理している人向けです。

/User/test/work(no git)
├── demo-project(git repository)
│   ├── index.js
│   ├── node_modules
│   ├── package-lock.json
│   └── package.json
└── nested-project(git repository)
    ├── backend(included package.json)
    └── frontend(included package.json)

Aikido Safe Chainをグローバルインストールしセットアップを済ませてから使ってください。

使い方は以下の形式が基本になります。

./npm-security-scanner /User/test/work

上記コマンドの実行結果は以下です。

🔍 NPM Security Scanner v1.3.0
Target directory: /User/test/work

🔧 Checking Safe Chain installation...
🔧 Checking Safe Chain setup status...
  ℹ️  Safe Chain is installed but setup may not be complete in current shell
✅ Safe Chain is properly installed and configured
🔍 Searching for NPM projects in ....
  📁 Found: demo-project
  📁 Found: nested-project/backend
  📁 Found: nested-project/frontend
🎯 Found 3 NPM project(s)

📋 NPM Projects to be scanned:
  1. demo-project
  2. nested-project/backend
  3. nested-project/frontend

Do you want to proceed with the security scan? [y/N]: n
🚫 Scan canceled by user

「Shai-Hulud」のメモ

感染範囲がかなり大きいとのこと。正直全てのプロジェクトを一旦疑った方がいいです。
感染時にはアカウントの乗っ取りや秘密鍵を窃取されます。

ツールの動き

仕組み自体は単純です。
Aikido Safe Chainはnpm install safe-chain-testなどインストール作業時にトリガーされてセキュリティスキャンを行います。そこで、

  1. ユーザから渡されたディレクトリ配下の全てのpackage.jsonを見つけ、そのディレクトリをプロジェクトのルートディレクトリとしてみなして列挙
  2. node_modulesディレクトリを削除しnpm install(ここでAikido Safe Chainがスキャン)
  3. 結果をjsonとhtmlで出力

といった流れで指定されたディレクトリ配下の全てのプロジェクトを列挙→列挙したプロジェクトを一つずつスキャン、という処理を自動化しています。

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?