Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Detect usage of Apache BeanUtils as dangerous #601 #629

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

marcelel
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #629 (5815c88) into master (fa7f7c4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #629   +/-   ##
=========================================
  Coverage     84.90%   84.90%           
  Complexity     1873     1873           
=========================================
  Files           154      154           
  Lines          5036     5036           
  Branches       1124     1124           
=========================================
  Hits           4276     4276           
  Misses          339      339           
  Partials        421      421           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa7f7c4...5815c88. Read the comment docs.

@h3xstream
Copy link
Member

Did you reproduce the security in the latest version ?

I don't want to integrate the new signature as it require some testing.
I had done some test before and the class property appears to be blocked in the latest version.

I will documented stuff I fund in this PR.

@h3xstream
Copy link
Member

h3xstream commented Apr 30, 2021

References for a security guard

Release notes

In version 1.9.2 now a special BeanIntrospector class was added which allows
suppressing this property. Note that this BeanIntrospector is NOT enabled by
default! Commons BeanUtils is a low-level library, and on this layer it cannot
be decided whether access to a certain property is legal or not. Therefore,
an application has to activate this suppressing BeanIntrospector explicitly.
This can be done with the following lines of code:

BeanUtilsBean bub = new BeanUtilsBean();
bub.getPropertyUtils().addBeanIntrospector(
    SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);

http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.4/RELEASE-NOTES.txt

Jira

We had some internal discussions about this topic. Because BeanUtils is a very low-level library and may be used widely I am reluctant to build in a change which ignores the class property by default. This may break existing code.

BeanUtils 1.9 intorduced the possibility to customize bean introspection. It should be possible to write a custom bean introspector which ignores the class property. We can implement such an introspector and ship it with BeanUtils. In order to make it active, it has to be registered explicitly at a BeanUtilsBean instance or the central BeanUtils object.

https://issues.apache.org/jira/browse/BEANUTILS-463

PR for the fix

Expected behavior taken from a test case..

    public void testAllowAccessToClassProperty() throws Exception {
        final BeanUtilsBean bub = new BeanUtilsBean();
        bub.getPropertyUtils().removeBeanIntrospector(SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS);
        final AlphaBean bean = new AlphaBean();
        String result = bub.getProperty(bean, "class");
        assertEquals("Class property should have been accessed", "class org.apache.commons.beanutils2.AlphaBean", result);
    }

apache/commons-beanutils#7

@marcelel
Copy link
Contributor Author

marcelel commented May 3, 2021

No, I didn't reproduce the security. I checked detection of usage BeanUtils.copyProperties. What do you suggest then?

Copy link
Member

@h3xstream h3xstream left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been reviewed and merged much sooner.

@h3xstream h3xstream merged commit df44f61 into find-sec-bugs:master Jul 11, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants