この記事の内容
実際に
コマンドインジェクションに 脆弱な MCPサーバーを 悪用する
MCPサーバーが
MCPサーバーは、
AIを 活用した 開発を 安全に 進める ための ベストプラクティス
AIを
脆弱なMCPサーバーがソフトウェア開発者にとってリスクとなる理由
開発者は、

一方、
さらに、
タスクを
解決する ために 新しい オープンソースの 依存関係を 追加する 場合、 ターミナルを 開いて npm install <package>を実行します。 新しい
MCPサーバーを 追加する 場合は、 Cursorの MCP定義ファイル .cursor/mcp.jsonを開き、 新しい サーバーを 定義します。
残念ながら、
脆弱なMCPサーバー
意図的に
この
以下は、
const server = new McpServer({
name: "npm JavaScript package management tools",
version: "1.0.0",
description: "Provides tools to get information about open source npm packages from the npmjs registry"
});
server.tool(
"getNpmPackageInfo",
"Get information about an npm package",
{
packageName: z.string()
},
async ({ packageName }) => {
const output = execSync(`npm view ${packageName}`, {
encoding: "utf-8",
});
return {
content: [
{
type: "text",
text: output
},
],
};
}
);Cursor用の新しいMCPサーバーを定義する
開発者が
{
"mcpServers": {
"npm-package-info": {
"command": "node",
"args": ["/Users/lirantal/projects/repos/mcp-server-npm"]
}
}続いて、
Cursorの
What is the last release date of the nodemon npm packageCursorはgetNpmPackageInfoとnodemonと
しかし、npm info <package name>コマンドを
コマンドインジェクションとは
次のreact; touch /tmp/hi:と

これは、
const output = execSync(`npm view ${packageName}`, {
encoding: "utf-8",
});攻撃者は、
MCPサーバーのコマンドインジェクション脆弱性を悪用する
まとめると、

Pythonや