0

When running pen tests on my SpringBoot application, I find the two following vulnerabilities:

nikto -ssl -h https://localhost:8181
...
+ Allowed HTTP Methods: GET, HEAD, POST, PUT, DELETE, OPTIONS 
+ OSVDB-397: HTTP method ('Allow' Header): 'PUT' method could allow clients to save files on the web server.
+ OSVDB-5646: HTTP method ('Allow' Header): 'DELETE' may allow clients to remove files on the web server.

It can also be observed by running:

curl -k -i --request-target "*" -X OPTIONS https://localhost:8181
...
HTTP/1.1 200 
Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS

I tried, but in vain, to configure/tune my SpringBoot application in order to avoid this issue

My objective was to return a HTTP header with only "Allow: GET, POST".

When investigating that possibility, I found that the answer to the "OPTIONS *" query was done in CoyoteAdapter:

    protected boolean postParseRequest(org.apache.coyote.Request req,
                                       Request request,
                                       org.apache.coyote.Response res,
                                       Response response) throws IOException, ServletException {
    ...
        if (undecodedURI.equals("*")) {
            if (req.method().equalsIgnoreCase("OPTIONS")) {
                StringBuilder allow = new StringBuilder();
                allow.append("GET, HEAD, POST, PUT, DELETE, OPTIONS");

Here, it seems that the "allow" tag is hardcoded: I can't modify it!

Any idea to avoid the detection of the vulnerabilities?

*this question is the continuation of

Philippe MESMEUR
  • 737
  • 8
  • 22
  • DELETE may appear on OPTIONS response but if there's no DELETE on controllers then a 405 will be returned. Look [here](https://stackoverflow.com/questions/42367975/disable-http-options-method-in-spring-boot-application) and [here](http://www.luv2code.com/2020/01/06/spring-rest-api-how-to-disable-http-delete-put-methods/) about how to disable a method. – LMC Jun 08 '22 at 14:40
  • And the same thing goes for PUT - this message is misleading. – stdunbar Jun 08 '22 at 15:04

0 Answers0