In any web application security, apart from user information security like user credentials, personal information and payment details etc. It must very important to take care user content whether it is user specific personalized sensitive content or content which is being shared with third-party services.
Following are the must-read articles to put some level of security in web content:
Properly configuring server MIME types
There are several ways incorrect MIME types can cause potential security problems with your site. This article explains some of those and shows how to configure your server to serve files with the correct MIME types.
HTTP Strict Transport Security
Strict-Transport-Security:HTTP header lets a website specify that it may only be accessed using HTTPS.
HTTP access control
The Cross-Origin Resource Sharing standard provides a way to specify what content may be loaded from other domains. You can use this to prevent your site from being used improperly; in addition, you can use it to establish resources that other sites are expressly permitted to use.
Content Security Policy
An added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement or distribution of malware. Code is executed by the victims and lets the attackers bypass access controls and impersonate users. According to the Open Web Application Security Project, XSS was the seventh most common Web app vulnerability in 2017.
The X-Frame-Options response header
X-Frame-Options: HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a
<frame>. Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.
Securing Your Site using Htaccess
It is the best way to secure your site using the .htaccess file. You can blacklist IPs, restrict access to certain areas of website, protect different files, protect against image hotlinking, and a lot more.