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:

  1. a Lt; Security-lock & gt; is an empty & lt; Auth-constraint & gt; & lt; Url-pattern & gt; * jsp and & lt; Http-method & gt; On GET on which on JSP files for all will block request (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;    
  2. Create a filter , which is & lt; Url-pattern & gt; of * .jsp and basically does the following in the doFilter () 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

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -