
Securing web applications and websites is a complex task, and harder when security was not considered from the development stage. However, some security controls that reduce the attack surface can still be implemented later; most of them are about web server configuration or content.
Below we use "web applications" generically for any service, application or website running over HTTP, and focus on security issues that can easily be solved with configuration or simple application changes.
OSINT and information gathering
OSINT (Open Source Intelligence) is a method of collecting and analysing information that is publicly available in open sources, such as websites, social networks, forums, blogs, news articles and other public sources.
We must do everything we can so that sensitive information is not made public, voluntarily or involuntarily, through metadata, meta tags, comments and so on.
We wrote about this topic in more detail here.
Server and web service fingerprinting
Fingerprinting is the process of determining the type and version of the software used by the publicly exposed services of a server. Attackers can use this information to identify known vulnerabilities and exploit them to compromise the web server and gain unauthorised access to sensitive data.
We covered this vulnerability in more detail in: Fingerprinting: identifying the web server and its services
HTTP security headers
Security headers are directives web applications use to configure protection features in web browsers. Based on them, browsers make client-side vulnerabilities such as Cross-Site Scripting (XSS), clickjacking and code injection harder to exploit. Among them:
- HSTS (HTTP Strict Transport Security): forces HTTPS connections
- CSP (Content Security Policy): defines trusted hosts for loading scripts and resources; anything else is blocked.
- X-XSS-Protection: was meant to detect and block attempts to inject malicious scripts (deprecated in modern browsers; CSP is the replacement).
- Referrer-Policy: controls how much referrer information is sent, helping against information leakage.
- X-Frame-Options: helps protect web applications against clickjacking.
- X-Content-Type-Options: helps protect web applications against MIME type confusion attacks.
Read more in: HTTP Security Headers: extra client-side protection
Cookies
Cookies are small text files that can contain sensitive information such as the user's session ID. Cookies have attributes called flags which, if set correctly, can stop attackers from stealing them through attacks on the web application.
More about this in: Setting cookies correctly to prevent attacks
Old backups, changelogs, readme files, composer.json etc.
Changelogs and readme files are documents with information about the changes and updates made to a web application. They are important for tracking how the application evolves and which issues or vulnerabilities were fixed. However, they can be dangerous if left public on the web server.
Attackers can use this information to identify known vulnerabilities or security issues that were fixed and may still be present in older versions of the application. They can also use it to identify the exact version of the application and look for vulnerabilities specific to that version.
Although these documents are important for developers, they should not be left public on the web server; delete them or restrict public access to them.
Directory listing
Web servers are often configured to list the contents of directories that have no index page automatically. This can help an attacker quickly identify the resources in a folder and move straight to analysing and exploiting them.
In this article we explain step by step how to disable directory listing.
