
Docker 기반 실습 환경으로, Java 웹 애플리케이션에서 Log4Shell(CVE-2021-44228) 취약점을 검증하고, 완화 조치를 테스트하며, LDAP 및 JNDI 인젝션을 통한 원격 코드 실행(RCE) 악용을 시뮬레이션합니다.
이 도구를 사용하면 사용자가 제공한 Java 및 Log4J 버전에 대해 간단한 Java 웹 앱이 CVE-2021-44228에 취약한지 확인할 수 있습니다.
또한 [선택적으로] 몇 가지 사전 정의된 완화 조치 중 하나를 적용할 수 있습니다.
log4shell_validator.py로 구동되는 시뮬레이션 랩은 docker-compose를 사용하여 log4j 취약점을 악용하고 취약한 머신에서 RCE를 얻는 과정을 시뮬레이션합니다.
먼저, 일부 도커 이미지를 빌드해야 합니다. ./build_images.sh 스크립트가 이를 처리합니다.
공격 시뮬레이션은 다음과 같은 방식으로 수행됩니다:
/2021-44228-via-message에서 GET 호출을 받으면 항상 User-Agent 헤더 필드를 기록합니다. 이 애플리케이션의 코드는 ./poc_template에서 확인할 수 있습니다../exploit.sh 스크립트를 실행합니다.cd marshalsec/ ;mvn clean package -DskipTests ;cd -./build-images.sh를 실행하십시오.python log4shell_validator.py --java-version 8 --log4j-version 2.12.1을 실행하십시오.~/workspace/CVE-2021-44228-playground$ python log4shell_validator.py --help
usage: log4shell_validator.py [-h] [--java-version JAVA_VERSION] --log4j-version LOG4J_VERSION [--no-cleanup] [--disable-trust-url] [--remove-jndi-lookup-class] [--disable-message-lookup] [--debug]
[--exploit-via-thread-context]
log4j-vulnerability-tester
optional arguments:
-h, --help show this help message and exit
--java-version JAVA_VERSION
version of java to be used
--log4j-version LOG4J_VERSION
version of log4j to be used
--no-cleanup Don't delete used containers.
--disable-trust-url Disable the LDAP trustURLCodebase setting on the victim app
--remove-jndi-lookup-class
Remove the JNDI Lookup class from the log4j jar file
--disable-message-lookup
Disable the JNDI message lookup in the victim app's JVM
--debug Display all container's logs
--exploit-via-thread-context
By sending the payload to an HTTP handler which makes use of Custom logging with ThreadContext, attempt to bypass the no-message-lookup mitigation
이 검증기는 Java7/8의 여러 조합과 다양한 Log4J2 버전으로 테스트되었습니다. 더 많은 예제는 github actions 탭의 확장 테스트 파이프라인을 참조하십시오.
현재까지 다음 완화 조치가 구현되었습니다:
com.sun.jndi.ldap.object.trustURLCodebase 속성을 False로 설정합니다.-Dlog4j2.formatMsgNoLookups=True또한, 메시지 조회 비활성화를 우회할 수 있는 익스플로잇 벡터를 테스트하기 위해 새로운 플래그가 추가되었습니다: --exploit-via-thread-context
이 소프트웨어는 순수하게 연구 목적과 효과적인 완화 기법 개발을 위해 만들어졌으며, 명시적으로 승인된 경우를 제외하고 시스템을 공격하는 데 사용하도록 의도되지 않았습니다. 프로젝트 유지 관리자는 소프트웨어의 오용에 대해 책임을 지지 않습니다. 책임감 있게 사용하십시오.