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

Fix vulnerability CVE-2022-41923 #1230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions grails-app/conf/spring/resources.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import be.cytomine.spring.CustomAjaxAwareAuthenticationEntryPoint
import be.cytomine.spring.CustomDefaultRedirectStrategy
import be.cytomine.spring.CustomSavedRequestAwareAuthenticationSuccessHandler
import be.cytomine.web.CytomineMultipartHttpServletRequest
import be.cytomine.PatchedInterceptUrlMapFilterInvocationDefinition
import grails.plugin.springsecurity.SpringSecurityUtils
import grails.plugin.springsecurity.web.authentication.AjaxAwareAuthenticationSuccessHandler
import grails.util.Holders
Expand Down Expand Up @@ -93,4 +94,11 @@ beans = {
targetBeanName = 'currentRoleService'
proxyTargetClass = true
}

def conf = SpringSecurityUtils.securityConfig
objectDefinitionSource(be.cytomine.PatchedInterceptUrlMapFilterInvocationDefinition) {
if (conf.rejectIfNoRule instanceof Boolean) {
rejectIfNoRule = conf.rejectIfNoRule
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package be.cytomine

import grails.plugin.springsecurity.web.access.intercept.InterceptUrlMapFilterInvocationDefinition
import org.springframework.web.util.UrlPathHelper

import javax.servlet.http.HttpServletRequest

class PatchedInterceptUrlMapFilterInvocationDefinition extends InterceptUrlMapFilterInvocationDefinition {

private static final UrlPathHelper urlPathHelper = new UrlPathHelper()

@Override
protected String calculateUri(HttpServletRequest request) {
String requestUri = urlPathHelper.getRequestUri(request)
stripContextPath(requestUri, request)
}

protected String stripContextPath(String uri, HttpServletRequest request) {
String contextPath = request.contextPath
if (contextPath && uri.startsWith(contextPath)) {
uri = uri.substring(contextPath.length())
}
uri
}

}