🇰🇷 한글 설명
PHP 5.x 및 7.x에서 Zend OpCache의 공유 메모리 취약점으로, 공유 호스팅 환경에서 자식 PHP 프로세스들이 단일 OpCache 캐시를 공유하면서 권한 분리를 우회할 수 있습니다. 악의적인 사용자가 다른 사용자의 PHP 스크립트를 읽거나 실행하여 CMS 데이터베이스 접근권한을 포함한 민감 정보에 접근할 수 있습니다.
💡 쉬운 설명
PHP의 코드 캐싱 기능인 OpCache가 여러 사용자 간에 캐시를 공유하면서, 한 사용자가 다른 사용자의 코드를 실행할 수 있게 되는 문제입니다. 공유 호스팅에서 호스팅 회사의 다른 고객 파일에 접근하여 데이터베이스 정보를 탈취할 수 있다는 뜻입니다.
🇺🇸 원문 (English)
An issue was discovered in PHP 5.x and 7.x, when the configuration uses apache2handler/mod_php or php-fpm with OpCache enabled. With 5.x after 5.6.28 or 7.x after 7.0.13, the issue is resolved in a non-default configuration with the opcache.validate_permission=1 setting. The vulnerability details are as follows. In PHP SAPIs where PHP interpreters share a common parent process, Zend OpCache creates a shared memory object owned by the common parent during initialization. Child PHP processes inherit the SHM descriptor, using it to cache and retrieve compiled script bytecode ("opcode" in PHP jargon). Cache keys vary depending on configuration, but filename is a central key component, and compiled opcode can generally be run if a script's filename is known or can be guessed. Many common shared-hosting configurations change EUID in child processes to enforce privilege separation among hosted users (for example using mod_ruid2 for the Apache HTTP Server, or php-fpm user settings). In these scenarios, the default Zend OpCache behavior defeats script file permissions by sharing a single SHM cache among all child PHP processes. PHP scripts often contain sensitive information: Think of CMS configurations where reading or running another user's script usually means gaining privileges to the CMS database.
📍 영향받는 시스템
PHP 5.6.28 이전, PHP 7.0.13 이전 버전 (apache2handler/mod_php 또는 php-fpm with OpCache enabled)
⚔️ 공격 벡터
공유 호스팅 환경에서 다른 사용자의 PHP 스크립트 파일명을 알거나 추측하여 OpCache 공유메모리에서 컴파일된 바이트코드를 검색 및 실행
🛡️ 대응 방법
PHP를 5.6.28 이상 또는 7.0.13 이상으로 업그레이드하거나 opcache.validate_permission=1 설정 활성화
🔧 검증 코드
PHP 버전이 5.6.28+ 또는 7.0.13+이고, OpCache가 활성화되어 있으면서 opcache.validate_permission이 1일 때 패치됨. 오래된 버전이거나 validate_permission이 0이면 취약.
php -v && php -r 'echo "OpCache: " . ini_get("opcache.enable") . ", Permission Check: " . ini_get("opcache.validate_permission") . PHP_EOL;'