diff --git a/jspwiki-http/src/main/resources/META-INF/web-fragment.xml b/jspwiki-http/src/main/resources/META-INF/web-fragment.xml deleted file mode 100644 index ca276a2d6b..0000000000 --- a/jspwiki-http/src/main/resources/META-INF/web-fragment.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - CsrfProtectionFilter - org.apache.wiki.http.filter.CsrfProtectionFilter - - - - CsrfProtectionFilter - /* - - - - - COEPFilter - org.apache.wiki.http.filter.COEPFilter - - - - COEPFilter - /* - - - - CORPFilter - org.apache.wiki.http.filter.CORPFilter - - - - CORPFilter - /* - - - - ContentTypeOptionsFilter - org.apache.wiki.http.filter.ContentTypeOptionsFilter - - - - ContentTypeOptionsFilter - /* - - - - CrossDomainFilter - org.apache.wiki.http.filter.CrossDomainFilter - - - - CrossDomainFilter - /* - - - - ReferrerPolicyFilter - org.apache.wiki.http.filter.ReferrerPolicyFilter - - - - ReferrerPolicyFilter - /* - - - - STSFilter - org.apache.wiki.http.filter.STSFilter - - - - STSFilter - /* - - - \ No newline at end of file diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java b/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java index e076e34951..c70f1bca6e 100644 --- a/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java +++ b/jspwiki-util/src/main/java/org/apache/wiki/util/PropertyReader.java @@ -469,7 +469,7 @@ static void setWorkDir( final ServletContext servletContext, final Properties pr LOG.info("ServletContext's temporary directory not found. Setting jspwiki.workDir to system's temporary directory: {}", defaultTmpDir); } } else { - LOG.info("jspwiki.workDir is already set to: {}", workDir); + LOG.debug("jspwiki.workDir is already set to: {}", workDir); } } diff --git a/jspwiki-war/src/main/webapp/Delete.jsp b/jspwiki-war/src/main/webapp/Delete.jsp index 1081b5c20e..345341eab2 100644 --- a/jspwiki-war/src/main/webapp/Delete.jsp +++ b/jspwiki-war/src/main/webapp/Delete.jsp @@ -29,6 +29,7 @@ <%@ page import="org.apache.wiki.tags.BreadcrumbsTag" %> <%@ page import="org.apache.wiki.tags.BreadcrumbsTag.FixedQueue" %> <%@ page import="org.apache.wiki.ui.TemplateManager" %> +<%@ page import="org.apache.wiki.http.filter.CsrfProtectionFilter" %> <%@ page import="org.apache.wiki.util.HttpUtil" %> <%@ page import="org.apache.wiki.util.TextUtil" %> <%@ page errorPage="/Error.jsp" %> @@ -39,6 +40,10 @@ %> <% + if( !CsrfProtectionFilter.isCsrfProtectedPost( request ) ) { + response.sendRedirect( "/error/Forbidden.html" ); + return; + } Engine wiki = Wiki.engine().find( getServletConfig() ); // Create wiki context and check for authorization Context wikiContext = Wiki.context().create( wiki, request, ContextEnum.PAGE_DELETE.getRequestContext() ); diff --git a/jspwiki-war/src/main/webapp/Install.jsp b/jspwiki-war/src/main/webapp/Install.jsp index 0f7a7fd285..7c578959b5 100644 --- a/jspwiki-war/src/main/webapp/Install.jsp +++ b/jspwiki-war/src/main/webapp/Install.jsp @@ -29,6 +29,7 @@ <%@ page import="org.apache.logging.log4j.LogManager" %> <%@ page import="java.util.ResourceBundle" %> <%@ page import="java.text.MessageFormat" %> +<%@ page import="org.apache.wiki.http.filter.CsrfProtectionFilter" %> <%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %> @@ -54,6 +55,10 @@ ResourceBundle rb = Preferences.getBundle( wikiContext, "CoreResources" ); // If user hit "submit" button, validate and install them if( request.getParameter("submit") != null ) { + if( !CsrfProtectionFilter.isCsrfProtectedPost( request ) ) { + response.sendRedirect( "/error/Forbidden.html" ); + return; + } validated = installer.validateProperties(); if ( validated ) { diff --git a/jspwiki-war/src/main/webapp/Rename.jsp b/jspwiki-war/src/main/webapp/Rename.jsp index d456ac2632..8eeb57f5ce 100644 --- a/jspwiki-war/src/main/webapp/Rename.jsp +++ b/jspwiki-war/src/main/webapp/Rename.jsp @@ -32,6 +32,7 @@ <%@ page import="org.apache.wiki.tags.BreadcrumbsTag.FixedQueue" %> <%@ page import="org.apache.wiki.ui.TemplateManager" %> <%@ page import="org.apache.wiki.util.TextUtil" %> +<%@ page import="org.apache.wiki.http.filter.CsrfProtectionFilter" %> <%@ page errorPage="/Error.jsp" %> <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %> <%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %> @@ -41,6 +42,10 @@ %> <% + if( !CsrfProtectionFilter.isCsrfProtectedPost( request ) ) { + response.sendRedirect( "/error/Forbidden.html" ); + return; + } Engine wiki = Wiki.engine().find( getServletConfig() ); // Create wiki context and check for authorization Context wikiContext = Wiki.context().create( wiki, request, ContextEnum.PAGE_RENAME.getRequestContext() ); diff --git a/jspwiki-war/src/main/webapp/WEB-INF/web.xml b/jspwiki-war/src/main/webapp/WEB-INF/web.xml index 83da270d2d..86bf0d69ae 100644 --- a/jspwiki-war/src/main/webapp/WEB-INF/web.xml +++ b/jspwiki-war/src/main/webapp/WEB-INF/web.xml @@ -86,6 +86,80 @@ /wiki/* *.jsp + + + CsrfProtectionFilter + org.apache.wiki.http.filter.CsrfProtectionFilter + + + + CsrfProtectionFilter + /* + + + + + COEPFilter + org.apache.wiki.http.filter.COEPFilter + + + + COEPFilter + /* + + + + CORPFilter + org.apache.wiki.http.filter.CORPFilter + + + + CORPFilter + /* + + + + ContentTypeOptionsFilter + org.apache.wiki.http.filter.ContentTypeOptionsFilter + + + + ContentTypeOptionsFilter + /* + + + + CrossDomainFilter + org.apache.wiki.http.filter.CrossDomainFilter + + + + CrossDomainFilter + /* + + + + ReferrerPolicyFilter + org.apache.wiki.http.filter.ReferrerPolicyFilter + + + + ReferrerPolicyFilter + /* + + + + STSFilter + org.apache.wiki.http.filter.STSFilter + + + + STSFilter + /* + 10 diff --git a/jspwiki-war/src/main/webapp/Workflow.jsp b/jspwiki-war/src/main/webapp/Workflow.jsp index 67d26388db..23b4721867 100644 --- a/jspwiki-war/src/main/webapp/Workflow.jsp +++ b/jspwiki-war/src/main/webapp/Workflow.jsp @@ -34,6 +34,7 @@ <%@ page import="org.apache.wiki.workflow.NoSuchOutcomeException" %> <%@ page import="org.apache.wiki.workflow.Outcome" %> <%@ page import="org.apache.wiki.workflow.Workflow" %> +<%@ page import="org.apache.wiki.http.filter.CsrfProtectionFilter" %> <%@ page import="org.apache.wiki.workflow.WorkflowManager" %> <%@ page errorPage="/Error.jsp" %> <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %> @@ -55,6 +56,10 @@ if( "decide".equals(request.getParameter("action")) ) { + if( !CsrfProtectionFilter.isCsrfProtectedPost( request ) ) { + response.sendRedirect( "/error/Forbidden.html" ); + return; + } try { // Extract parameters for decision ID & decision outcome @@ -78,6 +83,10 @@ } if( "abort".equals(request.getParameter("action")) ) { + if( !CsrfProtectionFilter.isCsrfProtectedPost( request ) ) { + response.sendRedirect( "/error/Forbidden.html" ); + return; + } try { // Extract parameters for decision ID & decision outcome