0

If you follow this article Azure Blog, you can remove the Server, X-Powered-By and MVC version which is great.

You can also achieve similar with a custom IIS module with the following method:

private void OnPreSendRequestHeaders(object sender, EventArgs e)
{
   HttpContext.Current?.Response.Headers.Remove("Server");
   HttpContext.Current?.Response.Headers.Remove("X-AspNet-Version");
   HttpContext.Current?.Response.Headers.Remove("X-AspNetMvc-Version");
   HttpContext.Current?.Response.Headers.Remove("X-Powered-By");
}

However, if you send the following query string:

https://yourAppService.azurewebsites.net/test.txt:

You manage to avoid all the steps you've taken to avoid sending the headers you are trying to keep away from potential hackers.

Sample Request:

Sample Request

Sample Response: enter image description here

Is there a way to completely remove these headers from ALL responses, and not just requests the app manages to handle gracefully? I have managed to remove the headers from 99% of responses, but not all!

UPDATE:

I have also found if you use PostMan to send a GET request to

https://yourSite.azurewebsites.net/400errortest%00

you get

enter image description here

UPDATE:

The request to /test.txt: was reported fixed by MS on the 26th June 2017. I can confirm it is fixed for this scenario.

Requests to https://yourSite.azurewebsites.net/400errortest%00 via PostMan still return a Server Header which is not great.

Ian Robertson
  • 2,652
  • 3
  • 28
  • 36
  • We could give our [feedback](https://feedback.azure.com/forums/169385-web-apps) to azure team that if we use the url end with `:` to visit the azure website that we will get 500 error, the default action should be 404 error. – Tom Sun - MSFT Feb 17 '17 at 14:28
  • I added a suggestion: https://feedback.azure.com/forums/169385-web-apps/suggestions/18384928-remove-sensitive-information-from-headers please vote for it if you would like to get this issue resolved. – Ian Robertson Feb 19 '17 at 12:56

1 Answers1

0

If we use the url end with : to visit the azure website that we will get 500 error, the default action should be 404 error. Azure team opened an internal bug and plan to fix it.

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • Thanks Tom - I cant really mark this as the answer because its not possible to actually fix the problem yet as it requires action from the PaaS team. When/if the problem can be fixed, I may provide details of any config/code changes a dev has to make to fix this issue and accept my own answer at that point. – Ian Robertson Feb 20 '17 at 13:47