Skip to content

Fixed: Prevent deserialization of untrusted data in JMS listener#1078

Open
jacopoc wants to merge 2 commits intoapache:trunkfrom
jacopoc:fix-code-scanning/1158
Open

Fixed: Prevent deserialization of untrusted data in JMS listener#1078
jacopoc wants to merge 2 commits intoapache:trunkfrom
jacopoc:fix-code-scanning/1158

Conversation

@jacopoc
Copy link
Copy Markdown
Contributor

@jacopoc jacopoc commented Apr 8, 2026

  • Restrict XStream allowlist in UtilXml to the exact types handled by XmlSerializer.serializeSingle
  • Replace the broad java..* and org.apache.ofbiz..* wildcards in SafeObjectInputStream with an explicit minimal allowlist of the same safe types
  • Remove cus-obj custom Java deserialization support from XmlSerializer (both serialize and deserialize paths) as it allowed arbitrary Serializable objects over JMS
  • Move the isExport() authorization check before XmlSerializer.deserialize in AbstractJmsListener.runService so gadget chains cannot fire for non-exported or unknown services

@jacopoc jacopoc self-assigned this Apr 8, 2026
jacopoc added 2 commits April 9, 2026 09:11
… Java objects in XmlSerializer for security reasons
- Restrict XStream allowlist in UtilXml to the exact types handled by
  XmlSerializer.serializeSingle
- Replace the broad java..* and org.apache.ofbiz..* wildcards in
  SafeObjectInputStream with an explicit minimal allowlist of the same
  safe types
- Move the isExport() authorization check before XmlSerializer.deserialize
  in AbstractJmsListener.runService so gadget chains cannot fire for
  non-exported or unknown services
@jacopoc jacopoc force-pushed the fix-code-scanning/1158 branch from f3cf6a1 to 25e449d Compare April 9, 2026 07:28
@JacquesLeRoux
Copy link
Copy Markdown
Contributor

Hi Jacopo,

I'm not sure why you removed
"org.codehaus.groovy.runtime.GStringImpl", "groovy.lang.GString"
from SafeObjectInputStream::SafeObjectInputStream.
They were added because of https://s.apache.org/pitaw
But indeed the issue can't be reproduced once the PR patch applied.
Despite the code

    result.successMessageList = [
        "Categories updated: ${categoriesUpdated}",
        "Products updated: ${productsUpdated}"

still being in CatalogServices.groovy::createMissingCategoryAndProductAltUrls

Could it be related with now using Groovy 5.0.0-alpha-11, or another specific change?

@jacopoc
Copy link
Copy Markdown
Contributor Author

jacopoc commented Apr 9, 2026

@JacquesLeRoux This is just an experiment and work in progress.
At the moment you are not getting the error because the (less permissive) allow list that I have introduced is not used because the property allowListof SafeObjectInputStream is still the same as before.

@jacopoc jacopoc marked this pull request as draft April 9, 2026 08:56
@JacquesLeRoux
Copy link
Copy Markdown
Contributor

OK thanks, please let me know when I should review :)

@JacquesLeRoux JacquesLeRoux self-requested a review April 9, 2026 16:00
@jacopoc jacopoc marked this pull request as ready for review April 13, 2026 16:43
@jacopoc
Copy link
Copy Markdown
Contributor Author

jacopoc commented Apr 13, 2026

@JacquesLeRoux this PR is ready for review. I’d appreciate it if you could check whether all the previously reported issues (e.g., in ticket OFBIZ-10837 ) that were fixed at the time are still properly addressed.

@JacquesLeRoux
Copy link
Copy Markdown
Contributor

Hi Jacopo,

I tested the issues from the 2 1st related Jiras and reviewed the last related Jira, it's OK with me.

As I explained above you need to put back "org.codehaus.groovy.runtime.GStringImpl", "groovy.lang.GString" in SafeObjectInputStream::DEFAULT_ALLOWLIST_PATTERN.
Because if for a reason it's not in SafeObjectInputStream.properties, or SafeObjectInputStream.properties does not exist, then you cross the error fixed with https://issues.apache.org/jira/browse/OFBIZ-11398
It's a weak probability but can't be neglected.

On the other hand, "sun.util.calendar." can be removed from both SafeObjectInputStream::DEFAULT_ALLOWLIST_PATTERN. and SafeObjectInputStream.properties since it's no longer used in OFBiz current supported branches after https://issues.apache.org/jira/browse/OFBIZ-12721

For "Serialization of custom Java objects (cus-obj) is no longer supported. " I guess you decided that because none custom Java objects are serialised OOTB, or is there another reason?

I must say I did not completely check the change in createXStream::createXStream. At 1st glance it's OK.

The rest is OK with me.

@jacopoc
Copy link
Copy Markdown
Contributor Author

jacopoc commented Apr 15, 2026

@JacquesLeRoux, thank you.

I introduced these changes because I am working to fix this:
https://github.com/apache/ofbiz-framework/security/code-scanning/1158

I'd like to keep DEFAULT_ALLOWLIST_PATTERN as minimal as possible in order to easily allow framework setups that do not require to deserialize special objects, such as GString, that may open some security related concerns.

This is the primary reason to remove the ability to deserialize custom object (cus-obj) as they are difficult/impossible to check for safety.

Thanks for your note on removing "sun.util.calendar": I will have a look at it.

@JacquesLeRoux
Copy link
Copy Markdown
Contributor

I understand for custom object. Then another way must be found for OFBIZ-11398, even if It's a weak probability.

@jacopoc
Copy link
Copy Markdown
Contributor Author

jacopoc commented Apr 15, 2026

I think it is fine, assuming that the feature mentioned in OFBIZ-11398 requires the current configuration in SafeObjectInputStream.properties. There are many other features in OFBiz that work only with specific configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants