🇰🇷 한글 설명
PHPMailer 5.2.22 이전 버전의 msgHTML 메서드에서 기본 디렉토리가 설정되지 않을 경우, 상대 이미지 URL이 절대 로컬 파일 경로로 해석되어 시스템 파일이 이메일 첨부파일로 추가되는 취약점입니다. 필터링되지 않은 사용자 HTML이 처리되면 /etc/passwd 같은 민감한 파일이 노출될 수 있습니다.
💡 쉬운 설명
PHPMailer가 이메일 HTML의 상대 경로 이미지를 파일로 변환할 때, 기본 폴더 설정이 없으면 루트(/)부터 모든 파일을 접근합니다. 공격자가 민감한 파일 경로를 이미지로 위장하면 그 파일이 첨부되어 노출됩니다.
🇺🇸 원문 (English)
An issue was discovered in PHPMailer before 5.2.22. PHPMailer's msgHTML method applies transformations to an HTML document to make it usable as an email message body. One of the transformations is to convert relative image URLs into attachments using a script-provided base directory. If no base directory is provided, it resolves to /, meaning that relative image URLs get treated as absolute local file paths and added as attachments. To form a remote vulnerability, the msgHTML method must be called, passed an unfiltered, user-supplied HTML document, and must not set a base directory.
📍 영향받는 시스템
PHPMailer 5.2.22 이전 모든 버전
⚔️ 공격 벡터
필터링되지 않은 사용자 HTML을 msgHTML 메서드로 전달하고 setBasePath()를 설정하지 않은 경우, 상대 경로로 /etc/passwd 등 로컬 파일 접근 가능
🛡️ 대응 방법
PHPMailer를 5.2.22 이상으로 업데이트하거나 msgHTML 호출 시 setBasePath()로 안전한 기본 디렉토리를 명시적으로 지정
🔧 검증 코드
5.2.22 이상 버전이 표시되면 안전합니다. 5.2.22 미만이 나타나거나 패키지를 찾을 수 없으면 즉시 업데이트 필요
composer show phpmailer/phpmailer 2>/dev/null | grep Version | awk '{print $NF}'