How to disable GET requests to JSP page? -
I am fixing some old flaws and as part of a flaw, I need to make sure that some requests are only being posted is a form instead of JSP page application for a gET request, which presents another JSP page data do (I know against its wrong and MVC but it's too late to fix ), Because it is a JSP page Land, so we do not or can post requests so we can get request. In the case of malicious users, read the form and http: // host: 80 / somejsp.jsp? Param = value and param = value can send request as a GET from the browser. In that case, it becomes a violation, I need to ensure that a GET request has not been processed in a way to do this, follow the steps below in jsp page -
if (request.getMethod (). equals ( "gET")) {// the user reroute is not because it is a valid REQ} are there any other advantage The way?
two solutions:
-
a
Lt; Security-lock & gt;is an empty& lt; Auth-constraint & gt;& lt; Url-pattern & gt;which* jspand& lt; Http-method & gt; OnGETonon JSP files for all will blockrequest (as suggested by McDowell):& lt; Security-lock & gt; & Lt; Display-name & gt; Restrict GET requests to JSP files & lt; / Display-name & gt; & Lt; Web resource collection & gt; & Lt; Web-Resource-Name & gt; JSP file & lt; / Web-resource-name & gt; & Lt; URL pattern & gt; * Jsp. & Lt; / Url pattern & gt; & Lt; Http-method & gt; Received & lt; / Http-method & gt; & Lt; / Web resource collection & gt; & Lt; Auth-constraint / & gt; & Lt; / Safety-barrier & gt;Create a
filter, which is& lt; Url-pattern & gt;of* .jspand basically does the following in thedoFilter ()method. If (((HttpServletRequest request)) KgetMethod () K equivalent ( "GET")) ((Actiteepisrvet response) response) .andarrr (Actiteepisrvet response. Ssi_mattiodiooanooaoeload); } And {chain.doFilter (request, response); }
There is no need to be copied on all JSP pages that only Avadstet Akspasn Is prone to: The response is already committed errors
Comments
Post a Comment