Commons Logging
  1. Commons Logging
  2. LOGGING-130

Potential missing privileged block for class loader


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1
    • Fix Version/s: 1.1.2
    • Labels:
    • Environment:

      Windows 7 under Sun JRE 6 Update 13, 64-bit
      Running Commons HttpClient 3,1 w/ Commons Logging 1.1.1


      When attempting to instantiate a HttpClient, a call to LogFactory.getLog() is made. Going deeper, Commons Logging later attempts to make an unprivileged call to java.lang.ClassLoader.getParent(). Under systems with an installed SecurityManager (like mine), this may be forbidden.

      In particular, this call will require the RuntimePermission getClassLoader. In my particular case, I am attempting to sandbox specific segments of code, and thus cannot grant this permission to the user of HttpClient (and, thus, Commons Logging). However, I feel that Commons Logging should be able to trust itself to make a self-checked call to ClassLoader.getParent().

      The stack trace for my situation (trimmed off to assist you) is as follows:

      Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.SecurityException: Cannot request this permission from a tainted execution path (Caused by java.lang.SecurityException: Cannot request this permission from a tainted execution path)
      at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
      at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
      at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(
      at org.apache.commons.logging.LogFactory.getLog(
      at org.apache.commons.httpclient.HttpClient.<clinit>(
      ... 11 more
      Caused by: java.lang.SecurityException: Cannot request this permission from a tainted execution path
      at com.mmoui.manager.MinionSecurityManager.verifyUntainted(
      at com.mmoui.manager.MinionSecurityManager.checkPermission(
      at com.mmoui.manager.MinionSecurityManager.checkPermission(
      at java.lang.ClassLoader.getParent(
      at org.apache.commons.logging.impl.LogFactoryImpl.getLowestClassLoader(
      at org.apache.commons.logging.impl.LogFactoryImpl.getBaseClassLoader(
      at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(
      at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(
      at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(
      ... 15 more

      I feel that LogFactoryImpl.getLowestClassLoader's call to java.lang.ClassLoader.getParent() should be wrapped by AccessController.doPrivileged(). I can't think of any reason not to do this currently. This would allow my application to trust Commons Logging and not have to grant the RuntimePermission getClassLoader to the users of HttpClient.

      1. LOGGING-130.patch
        1 kB
        Dennis Lundberg

        Issue Links


          Thomas Neidhart made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Sebb made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.1.2 [ 12314498 ]
          Resolution Fixed [ 1 ]
          Dennis Lundberg made changes -
          Link This issue is duplicated by LOGGING-134 [ LOGGING-134 ]
          Dennis Lundberg made changes -
          Field Original Value New Value
          Attachment LOGGING-130.patch [ 12429101 ]
          Matthew P. Del Buono created issue -


            • Assignee:
              Matthew P. Del Buono
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: