Repository navigation
WW-5761 Enforce @StrutsParameter on the member OGNL resolves during parameter binding - #2109
Open
emilhuseyn wants to merge 1 commit into
Open
emilhuseyn wants to merge 1 commit into
emilhuseyn wants to merge 1 commit into
Conversation
…inding ParametersInterceptor sets a per-parameter guard on the binding stack's SecurityMemberAccess, created by ParameterAuthorizer.memberGuard and applied in isAccessible, so a drift between the authorizer's prediction and OGNL's name resolution fails closed. The authorizer stays the gate for paths that never reach isAccessible. Off by default behind struts.parameters.requireAnnotations.enforceOnResolvedMember, which only has effect together with struts.parameters.requireAnnotations. The guard lives in StrutsParameterMemberGuard so the authorizer only gains the factory method.
Contributor
Author
|
Once this one lands, I'll pick up WW-5787 (execAndWait sandbox) as you suggested, unless someone else is already on it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes WW-5761
StrutsParameterAuthorizer.isAuthorizedruns before OGNL and has to predict which accessor or field a parameter name will reach. If that prediction and OGNL's own name resolution ever differ, the value goes through a member nobody checked. This adds a second check at the point where OGNL resolves the member, behind a new constant that is off by default:With the flag off nothing changes:
ParametersInterceptorsets no guard and binding takes the same path as today.With the flag on (and
struts.parameters.requireAnnotationson),ParametersInterceptorasks the authorizer for aParameterMemberGuardfor each parameter and sets it on the binding stack'sSecurityMemberAccessjust beforestack.setParameter. It is removed when the loop ends.SecurityMemberAccess.isAccessibleasks the guard about every member OGNL resolves. As you pointed out, that bean isscope="prototype"and every value stack has its own instance, so the guard is never shared between requests.What the guard checks:
ModelDrivenmodel is exempt by identity, as in the authorizer.isAuthorizedaccepts today.Not changed: Map-backed models and custom
PropertyAccessors never reachisAccessible, so the authorizer stays the gate there.ParameterNameAware, the JSON and REST plugins andCookieInterceptorare untouched.Given orphan-oss/ognl#755, the authorizer side is kept small.
StrutsParameterAuthorizeronly gainsmemberGuard(...), a factory, and the depth count moves into a helper both methods use. The guard itself is the package-privateStrutsParameterMemberGuard.ParameterAuthorizer.memberGuardis a default method returningPERMIT_ALL, so a custom authorizer compiles and behaves as before.Tests:
ParameterMemberGuardTestbinds through a real OGNL value stack with no authorizer pre-check, so it shows the guard holding on its own: annotated and unannotated setters, fluent setters, public fields, overloads, nested depth, the null-handler case,ModelDriven, an object below the action, transition mode, removal after binding, and the interceptor with an authorizer whose prediction has drifted, rejected with the flag on and bound as before with the flag off or withoutrequireAnnotations.ParameterMemberGuardTest,ParameterAuthorizerTest,ParametersInterceptorTest,StrutsParameterAnnotationTestandSecurityMemberAccessTestpass locally on JDK 21, along with the fullcoresuite. I have not benchmarked the flag-on cost: one annotation lookup per member OGNL resolves on a root object, plus a scan of the public methods and fields when that member itself is unannotated.🤖 Generated with Claude Code