🇰🇷 한글 설명
Snappy PHP 라이브러리의 1.7.1 이전 버전에서 POSIX 환경 시 wkhtmltopdf 바이너리 경로 처리 시 버그가 존재합니다. escapeshellarg 함수의 잘못된 동작으로 인해 경로 검증이 실패하고, 설정이나 환경 변수를 통해 사용자가 제어할 수 있는 바이너리 경로가 삽입될 경우 명령어 인젝션이 가능합니다.
💡 쉬운 설명
웹사이트에서 PDF를 생성하는 Snappy 라이브러리에 보안 결함이 있습니다. 공격자가 시스템 명령어를 조작할 수 있는 바이너리 경로를 설정할 수 있어 위험합니다.
🇺🇸 원문 (English)
Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Prior to version 1.7.1, on POSIX, escapeshellarg(‘/usr/bin/wkhtmltopdf’) returns the literal string ‘/usr/bin/wkhtmltopdf’ with the single-quote characters included. is_executable() then looks for a file whose actual name contains those quote characters, which essentially never exists. The safe branch is dead code and $command always falls through to the raw, unescaped value. The rest of the arguments (options, input, output) are escaped correctly, so injection has to land in the binary string itself. That happens whenever the binary path is sourced from configuration that is user-influenced, derived from environment variables that ultimately come from request data, or concatenated with any user-controlled fragment. This issue has been patched in version 1.7.1.
📍 영향받는 시스템
Snappy PHP Library version < 1.7.1
⚔️ 공격 벡터
사용자가 제어할 수 있는 환경 변수 또는 설정을 통해 wkhtmltopdf 바이너리 경로에 악성 명령어 삽입
🛡️ 대응 방법
Snappy 라이브러리를 버전 1.7.1 이상으로 즉시 업그레이드하십시오.
🔧 검증 코드
출력된 버전 번호가 1.7.1 미만인 경우 취약한 버전이므로 업그레이드가 필요합니다.
php -r "require 'vendor/autoload.php'; echo \Snappy\Image\Pdf::VERSION;"