🇰🇷 한글 설명
PHP 의존성 관리자인 Composer의 Perforce::generateP4Command() 메서드에서 명령 주입 취약점이 발견되었습니다. composer.json 파일의 Perforce 연결 매개변수(포트, 사용자, 클라이언트)가 적절히 이스케이프되지 않아 공격자가 임의의 셸 명령을 실행할 수 있습니다.
💡 쉬운 설명
Composer 패키지 관리자의 설정 파일을 통해 악의적인 명령을 주입하여 컴퓨터를 제어할 수 있는 보안 결함입니다. 신뢰하지 않는 프로젝트의 composer.json을 실행할 때 위험합니다.
🇺🇸 원문 (English)
Composer is a dependency manager for PHP. Versions 1.0 through 2.2.26 and 2.3 through 2.9.5 contain a command injection vulnerability in the Perforce::generateP4Command() method, which constructs shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping. An attacker can inject arbitrary commands through these values in a malicious composer.json declaring a Perforce VCS repository, leading to command execution in the context of the user running Composer, even if Perforce is not installed. VCS repositories are only loaded from the root composer.json or the composer config directory, so this cannot be exploited through composer.json files of packages installed as dependencies. Users are at risk if they run Composer commands on untrusted projects with attacker-supplied composer.json files. This issue has been fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline).
📍 영향받는 시스템
Composer 1.0~2.2.26, 2.3~2.9.5
⚔️ 공격 벡터
악의적인 composer.json에서 Perforce VCS 저장소의 port/user/client 매개변수에 셸 메타문자를 삽입하여 명령 주입
🛡️ 대응 방법
Composer를 버전 2.2.27(LTS) 또는 2.9.6(mainline) 이상으로 업데이트
🔧 검증 코드
출력이 'Safe'면 패치된 버전, 'Vulnerable'이면 취약한 버전입니다.
composer --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | awk -F. '{if(($1==2 && $2==2 && $3>=27) || ($1==2 && $2>=9 && $3>=6) || $1>=3) print "Safe"; else print "Vulnerable"}'