Uploaded image for project: 'Santuario'
  1. Santuario
  2. SANTUARIO-337

ResourceResolver does thread-unsafe handling of the "secureValidation" flag

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Java 1.5.2
    • Java 1.5.4, Java 2.0.0
    • Java
    • Security Level: Public (Public issues, viewable by everyone)
    • None

    Description

      From ResourceResolver.getInstance(), with parts elided for brevity & clarity:

      for (ResourceResolver resolver : resolverList) {
      ResourceResolver resolverTmp = resolver;
      if (!resolver.resolverSpi.engineIsThreadSafe())

      { // generate a new instances of resolverSpi ... }

      // ...

      resolverTmp.resolverSpi.secureValidation = secureValidation;
      if ((resolverTmp != null) && resolverTmp.canResolve(uri, baseURI))

      { // Check to see whether the Resolver is allowed // check for certain types .... return resolverTmp; }

      }

      In case you didn't see it, the trouble is the juxtaposition of "resolverSpi.engineIsThreadSafe()" followed by code that sets "secureValidation" on the very same instance of the spi, whether or not it is thread safe.

      Meaning, if two threads resolve at the same time, and one thread is attempting secure resolution while the other is not, all the "thread safe" resolvers risk a race condition where they will now be in an uncertain state. Of course, it turns out that all the included resolvers declare themselves thread-safe, so this potentially magnifies the problem.

      In practice, this is not likely ever to occur, because any given application will likely share the same notion of "secureValidation".

      Three observations

      #1 - the secureValidation flag needs only be set for the resolver that is actually chosen

      #2 - the secureValidation flag should instead be passed as a parameter ResourceResolverSpi.engineResolve() method, not stored as data in the SPI instance.

      #3 - if there were ever a resolver to show up that isn't thread safe, and it also has properties, the logic above which creates a new instance of the SPI would discard the properties set on the registered spi. It turns out only the HTTP resolver uses these properties for anything, so this may not be problematic in the real world.

      Originally reported via email:
      http://article.gmane.org/gmane.text.xml.security.devel/7647

      Attachments

        1. SANTUARIO-337-try2.trunk.patch
          33 kB
          Eric Johnson
        2. SANTUARIO-337-try2.1.5.X.patch
          30 kB
          Eric Johnson
        3. resolver.patch
          32 kB
          Eric Johnson

        Activity

          People

            coheigea Colm O hEigeartaigh
            eric@tibco.com Eric Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: