I only have experience resolving this issue in Java, but I hope my solution has some translation to .NET that helps you. It looks like you're getting the issue "Often Misused: HTTP Method Override" reported by Fortify's WebInspect scanner. To resolve this for my team I implemented a filter that listens for our bad headers (x-http-method, x-http-method-override, x-method-override), sets status to 405 and breaks if they are found. See code below. I know this is not the most graceful solution, but it is the only one I found that satisfies the scan (throwing an error and booting the user did not satisfy).
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest hsReq = (HttpServletRequest) req;
HttpServletResponse hsRes = (HttpServletResponse) res;
hsRes.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
hsRes.setHeader("Pragma", "no-cache");
hsRes.setDateHeader("Expires", 0);
hsRes.setHeader("X-XSS-Protection", "1; mode=block");
hsRes.addHeader("X-Content-Type-Options", "nosniff");
hsRes.setHeader("Content-Security-Policy", "frame-ancestors 'none'; default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'");
hsRes.setHeader("X-FRAME-OPTIONS", "DENY");
hsRes.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains;");
// This resolves "Often Misused: HTTP Method Override"
hsRes.setHeader("Access-Control-Allow-Methods", "GET, POST");
String methodParam = hsReq.getParameter("_method");
if (methodParam != null){
LOG.error("\n Bad actor is attempting to use HTTP Method Tunneling. \n");
hsRes.reset();
hsRes.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
String xhmHeader = hsReq.getHeader("x-http-method");
String xhmoHeader = hsReq.getHeader("x-http-method-override");
String xmoHeader = hsReq.getHeader("x-method-override");
if ((xhmHeader != null) || (xhmoHeader != null) || (xmoHeader != null)){
LOG.error("\n Bad actor is attempting to use HTTP Method Tunneling. \n");
hsRes.reset();
hsRes.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
chain.doFilter(req, res);
}