The recently published vulnerability at Moonpig makes it clear that there is no place for complacency when it comes to securing the applications we create, even APIs.
The starting point for securing a web application or web site application involves implementing measures for the following:
In global.asax.cs:
X-AspNet-Version
In the web.config:
X-AspNetMvc-Version
In global.asax.cs:
X-Powered-By
In the web.config:
In the web.config:
User-agent:*
Disallow: /
The starting point for securing a web application or web site application involves implementing measures for the following:
- Authentication
- Authorisation
- SQL injection prevention
- XSS prevention
- CSRF prevention
- DOS prevention
- DDOS prevention
- Encrypting sensitive data
Avoid leaking internal implementation details.
Remove response headers
ServerIn global.asax.cs:
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
HttpContext.Current.Response.Headers.Remove("Server");
}
|
X-AspNet-Version
In the web.config:
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
|
X-AspNetMvc-Version
In global.asax.cs:
protected void Application_Start()
{
MvcHandler.DisableMvcResponseHeader = true;
}
|
X-Powered-By
In the web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
</system.webServer>
|
Disable tracing, debugging and verbose error messages
In the web.config:
<system.web>
<trace enabled=""false"" localOnly=""true"">
<compilation debug=""false"">
<customErrors mode=""RemoteOnly"">
</system.web>
|
Prevent click-jacking
Add response header
X-Frame-Options: SameOriginIn the web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="SAMEORIGIN" />
</customHeaders>
</httpProtocol>
</system.webServer>
|
Prevent listing in search engines
Add a "robots.txt" file to the root of your site, containing the following:User-agent:*
Disallow: /
Obscurity alone is insufficient to ensure application security.
I hope these simple measures help you to improve the security of your application.
I hope these simple measures help you to improve the security of your application.
Comments
Post a Comment