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

Ognl choosing method on unexported class rather than exported interface #286

Open
RoganDawes opened this issue Aug 2, 2024 · 0 comments

Comments

@RoganDawes
Copy link

RoganDawes commented Aug 2, 2024

Hi,

I ran into this problem which is by no means a showstopper for me, but one I am trying to understand.

I am using Ognl to be able to allow users to craft their own "toString" functions for arbitrary classes. One that has caused problems is an array of java.security.cert.X509Certificate, as one would get when nogotiating an SSL connection, and inspecting the server certs.

I tried to extract the subjectAlternativeNames of the first certificate using (https://docs.oracle.com/javase/8/docs/api/java/security/cert/X509Certificate.html#getSubjectAlternativeNames--) with the expression "[0].getSubjectAlternativeNames()", but received the following exception:

java.lang.IllegalAccessException: class ognl.OgnlRuntime cannot access class sun.security.x509.X509CertImpl (in module java.base) because module java.base does not export sun.security.x509 to unnamed module @5f16132a
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
at java.base/java.lang.reflect.Method.invoke(Method.java:560)
at ognl.OgnlRuntime.invokeMethodInsideSandbox(OgnlRuntime.java:882)
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:867)
at ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:1712)
at ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:47)
at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:110)
at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2352)

My first guess, not being familiar with the Ognl codebase, is that OgnlRuntime.findBestMethod() somehow needs to consider class interfaces and prioritise public interfaces over internal implementations when choosing the method to return.

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

No branches or pull requests

1 participant