Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WW-5407 Extend SecurityMemberAccess proxy detection to other proxies #911

Conversation

jefferyxhy
Copy link
Contributor

@jefferyxhy jefferyxhy commented Apr 9, 2024

WW-5407

Reason
Currently SecurityMemberAccess#isAccessible return true for a method of a proxy object, which expose the beans at risk of being changed. We need to have the ability to detect proxy object and reject the access if required.

See Jira card above for more details.

 

Changes/ Solution
currently in isAccessible -> checkProxyMemberAccess , it use disallowProxyMemberAccess && ProxyUtil.isProxyMember(member, target) which is not enough, as isProxyMember only matches the member directly from proxy class, and does not match those ones original from the target class.

 

So we update the isAccessible:

  • add one extra checking checkProxyAccess before checkProxyMemberAccess which is controlled by:
    • struts.disallowProxyObjectAccess : an new struts constant to enable or disable this checking (default as false)
    • if disallow, then we do the proxy checking against the target object.

 

Result & Impact

  • By default struts.disallowProxyObjectAccess as default, no difference.
  • Set struts.disallowProxyObjectAccess as true, access to any member of a proxy object will be rejected, including both proxy member and original member of class. Which means whenever chained parameter a.b.c.d.x has one part that is a proxy, we reject the set to the last x

@kusalk kusalk changed the title WW-5407 extend SecurityMemberAccess proxy detection to other proxies WW-5407 Extend SecurityMemberAccess proxy detection to other proxies Apr 9, 2024
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.4.4.Final</version>
<optional>true</optional>
Copy link
Member

Choose a reason for hiding this comment

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

core/pom.xml Outdated
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.4.4.Final</version>
Copy link
Member

Choose a reason for hiding this comment

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

As far I know this version won't work on JDK8 which is a base version for Struts 6.x

Copy link
Member

Choose a reason for hiding this comment

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

You are correct - downgraded to Hibernate 5 as this proxy detection code is identical :)

@jefferyxhy jefferyxhy force-pushed the issue/WW-5407-extend-SecurityMemberAccess-proxy-detection-to-proxies branch from b3578e2 to 0074b70 Compare April 9, 2024 04:46
@jefferyxhy jefferyxhy marked this pull request as ready for review April 9, 2024 04:52
@kusalk
Copy link
Member

kusalk commented Apr 9, 2024

Hi @lukaszlenart

@jefferyxhy is a colleague of mine at Atlassian who is helping implement some security enhancements.
I believe this one is ready for review now. I've given it a look over and it looks good to me. Let us know if there are any issues otherwise we can prepare an accompanying struts-site PR

@kusalk kusalk requested a review from lukaszlenart April 9, 2024 05:06
Comment on lines 135 to 136
if (hasMember(clazz, member))
return true;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be inlined?

return hasMember(clazz, member);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lukaszlenart updated. Thanks

Copy link
Member

@lukaszlenart lukaszlenart left a comment

Choose a reason for hiding this comment

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

Great 👏 LGTM 👍

@kusalk kusalk merged commit 0aa2f26 into apache:master Apr 11, 2024
7 checks passed
@kusalk kusalk deleted the issue/WW-5407-extend-SecurityMemberAccess-proxy-detection-to-proxies branch April 11, 2024 09:16
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.

3 participants