🇰🇷 한글 설명
PhpWeasyPrint 2.5.1 미만 버전에서 바이너리 경로 검증 로직의 오류로 인해 발생하는 쉘 명령 주입 취약점입니다. escapeshellarg()로 인해 변형된 경로를 is_executable()로 검사하면서 실제 실행 파일 검증이 무력화되고, 설정된 바이너리 경로가 시스템 명령어로 직접 전달될 수 있습니다.
💡 쉬운 설명
PDF를 만드는 도구의 경로를 확인하는 과정에서 실수로 보안 검사를 건너뛰게 되는 버그가 있습니다. 이로 인해 공격자가 악성 명령어를 입력하면 서버에서 원치 않는 명령이 실행될 수 있습니다.
🇺🇸 원문 (English)
PhpWeasyPrint is a PHP library allowing PDF generation from a URL or an HTML page. Prior to version 2.5.1, `pontedilana/php-weasyprint` builds the shell command for WeasyPrint by passing the binary path through `escapeshellarg()` first and then checking the *quoted* result with `is_executable()`. On POSIX `escapeshellarg('/usr/local/bin/weasyprint')` returns `'/usr/local/bin/weasyprint'` with the single-quote characters as part of the string, so `is_executable()` looks for a file whose actual name includes those quotes. That file never exists, the "safe" branch is dead code, and the raw `$binary` string (set via the constructor or `setBinary()`) flows directly into `Symfony\Component\Process\Process::fromShellCommandline()`. Any deployment whose binary path is sourced from configuration, an environment variable, or a per-tenant setting reaches a shell-command-injection sink. The library is documented as a one-to-one substitute for KnpLabs/snappy and inherited the exact pre-fix codepath KnpLabs patched in GHSA-vpr4-p6fq-85jc. PhpWeasyPrint version 2.5.1 contains a patch for the issue.
📍 영향받는 시스템
PhpWeasyPrint version < 2.5.1
⚔️ 공격 벡터
설정 파일, 환경 변수 또는 테넌트 설정을 통해 조작된 바이너리 경로를 전달하여 쉘 명령 주입
🛡️ 대응 방법
PhpWeasyPrint를 최신 버전인 2.5.1 이상으로 업데이트하십시오.
🔧 검증 코드
출력된 버전이 2.5.1 미만이면 취약한 상태이며, 2.5.1 이상이면 안전합니다.
composer show pontedilana/php-weasyprint | grep 'versions'