🇰🇷 한글 설명
Perl용 PDF::WebKit 1.2 이하 버전은 to_pdf의 출력 경로와 _style_tag_for의 스타일시트 경로를 2-인자 open()으로 처리하여 OS 명령 주입이 가능합니다. 파이프(|)나 리다이렉트(>, >>)가 포함된 값이 명령 실행 또는 파일 쓰기/덮어쓰기로 이어질 수 있습니다.
💡 쉬운 설명
PDF를 만들 때 쓰는 파일 경로에 특수 문자를 넣으면 프로그램이 그 내용을 명령어처럼 실행할 수 있습니다. 외부 입력을 그대로 경로로 쓰는 경우 공격자가 서버에서 명령을 실행할 수 있습니다.
🇺🇸 원문 (English)
PDF::WebKit versions through 1.2 for Perl allow OS command injection via a 2-arg open() of the output path in to_pdf and of stylesheet paths in _style_tag_for.
to_pdf reads the generated PDF back from its path argument, and _style_tag_for reads each entry of the stylesheets list, by assigning the path to a local @ARGV and reading it with the diamond operator, which opens each @ARGV element with Perl's 2-arg open(). A value that begins or ends with a pipe ("| cmd", "cmd |") is run as a command rather than opened as a file, and one that begins with a redirect ("> path", ">> path") opens that path for write or append. to_file forwards its path argument to to_pdf and reaches the same read.
Any caller that forwards untrusted input as the output path or as a stylesheets entry can run a command under the process UID; with the "cmd |" form the command's output is returned in place of the PDF, and with the "> path" form the named file is truncated. Stylesheets may only be added to an HTML source, so a URL or file source exposes the output path alone.
📍 영향받는 시스템
PDF::WebKit 1.2 이하 (Perl), 외부 입력을 출력 경로나 stylesheets에 전달하는 애플리케이션
⚔️ 공격 벡터
공격자가 출력 경로 또는 stylesheets 항목에 '| 명령' 또는 '> 파일경로' 형태의 값을 주입하여 프로세스 권한으로 명령 실행 또는 파일 덮어쓰기
🛡️ 대응 방법
PDF::WebKit을 1.2보다 최신 버전으로 업데이트하고, 외부 입력을 경로로 사용하지 않도록 검증하거나 2-인자 open 대신 3-인자 open을 사용하도록 패치
🔧 검증 코드
출력된 버전이 1.2 이하이면 취약하며, 해당 버전 이후 패치된 릴리스로 업그레이드가 필요하고, 명령이 아무 결과도 없으면 모듈이 설치되지 않은 것입니다.
perl -MPDF::WebKit -e 'print "$PDF::WebKit::VERSION\n"' 2>/dev/null || cpan -l 2>/dev/null | grep -i 'PDF::WebKit'