🇰🇷 한글 설명
hagent 커밋 761eec6까지의 버전에는 OS 명령어 주입 취약점이 존재합니다. MCP 클라이언트는 hagent_arduino 및 hagent_esp32 도구의 args 파라미터에 메타문자를 삽입하여 셸 명령을 실행할 수 있습니다. 공격자나 프롬프트 인젝션된 에이전트가 조작된 args를 전달하면, subprocess.run(shell=True)로 실행되는 arduino-cli 및 idf.py 명령에 주입되어 MCP 서버 사용자 권한으로 임의 명령이 실행됩니다.
💡 쉬운 설명
AI 도구에 전달되는 입력값에 악의적인 명령어를 몰래 섞으면, 서버에서 그 명령어가 실행될 수 있습니다. 이 때문에 공격자가 서버 권한을 얻을 수 있습니다.
🇺🇸 원문 (English)
hagent through commit 761eec6 contains an OS command injection vulnerability that allows MCP clients to execute shell commands by injecting metacharacters into the args parameter of the hagent_arduino and hagent_esp32 tools. Attackers or prompt-injected agents can supply crafted args interpolated into arduino-cli and idf.py commands run with subprocess.run(shell=True) to execute commands as the MCP server user.
📍 영향받는 시스템
hagent 커밋 761eec6 이하 버전 (hagent_arduino, hagent_esp32 도구 사용 환경)
⚔️ 공격 벡터
MCP 클라이언트 또는 프롬프트 인젝션된 에이전트가 args 파라미터에 셸 메타문자(;, |, &&, $() 등)를 삽입하여 OS 명령 실행
🛡️ 대응 방법
761eec6 이후의 패치된 hagent 버전으로 업데이트하고, args 입력을 셸 없이 리스트 형태로 전달하도록 subprocess 호출을 수정하며, 입력값 화이트리스트 검증을 적용
🔧 검증 코드
출력된 커밋 해시가 761eec6 이전이면 취약하며, 이후 커밋이거나 'hagent not found'이면 설치되지 않았거나 패치된 것으로 판단할 수 있습니다. 커밋 해시는 git log 결과로 직접 비교하세요.
cd "$(pip show hagent 2>/dev/null | grep -i location | cut -d' ' -f2)" 2>/dev/null && git log --oneline -1 2>/dev/null || (command -v hagent >/dev/null && hagent --version 2>/dev/null) || echo 'hagent not found'