You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org> on 2013/03/19 14:39:15 UTC

[jira] [Closed] (SANTUARIO-337) ResourceResolver does thread-unsafe handling of the "secureValidation" flag

     [ https://issues.apache.org/jira/browse/SANTUARIO-337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Colm O hEigeartaigh closed SANTUARIO-337.
-----------------------------------------

    
> ResourceResolver does thread-unsafe handling of the "secureValidation" flag
> ---------------------------------------------------------------------------
>
>                 Key: SANTUARIO-337
>                 URL: https://issues.apache.org/jira/browse/SANTUARIO-337
>             Project: Santuario
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: Java 1.5.2
>            Reporter: Eric Johnson
>            Assignee: Colm O hEigeartaigh
>            Priority: Minor
>             Fix For: Java 1.5.4, Java 2.0.0
>
>         Attachments: resolver.patch, SANTUARIO-337-try2.1.5.X.patch, SANTUARIO-337-try2.trunk.patch
>
>
> 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

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira