Spring is still falling through to remote access of XML files

Description

We’re still finding cases where Spring is falling through to remote access of XML files, schemas primarily, when it doesn’t have a way to find them locally. We have never to this point found a way to block it but it’s past time to solve this once and for all or file a bug with Spring, as this is a security risk.

Environment

None

Confluence content

Activity

Scott Cantor 
April 18, 2023 at 5:25 PM

They won’t fix it for compatibility reasons but after a quick test, it’s landing in the same try/catch frame if I raise a runtime exception, so I just converted to use a BeanDefinitionStoreException and cleaned up our custom class so it eliminates the duplication I had to do before.

Scott Cantor 
April 18, 2023 at 3:04 PM

They neglected to allow the overridden method to raise an exception so there’s no way to short-circuit what it’s doing. If I raise a runtime error I don’t know what that will do so I don’t prefer to go down that road and have to re-test. If they ever fix it, we’ll revisit.

Scott Cantor 
April 18, 2023 at 2:53 PM

We should be using a new enough Spring version now that they may have added a protected method I can hook to avoid some of the duplication I did.

Scott Cantor 
December 8, 2022 at 4:57 PM

Fix for the immediate issue in Spring and a canary test added to the new library. I will backport this to spring-extensions.

Scott Cantor 
December 8, 2022 at 3:31 PM

The problem isn’t that they don’t use an EntityResolver but that their ResourceEntityResolver class defaults to falling into http/s resolution.

Filed a Spring bug in case they decide to care, https://github.com/spring-projects/spring-framework/issues/29662

The problem is compounded by a gem of a comment inside JAXP in Java that basically says “if the ER returns null, should we really do it ourselves or return null?” Of course you know what they did. The only way around that is to throw an exception inside the EntityResolver.

Thus, the fix I found was to clone yet another Spring class and cut out the bad bits and add a log and throw.

I will add a canary test for this as well.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Created December 8, 2022 at 1:44 PM
Updated September 13, 2023 at 12:56 PM
Resolved April 18, 2023 at 3:04 PM