Security Hardening Writeup

Red Team Reconnaissance & Blue Team Defense

Red Team: Passive Information Gathering

Passive Reconnaissance

There are ways of gathering information about a website's security posture. Using a third-party tool to analyze my organization's HTTP response gave me an understanding of how my website uses HTTP security headers to protect the visitor.

1.2 HTTP Header Analysis

HTTP Security Headers Analysis

Missing Security Headers: DaveHat is missing several defensive headers such as Strict-Transport-Security, Content-Security-Policy, and X-Frame-Options. These are not necessarily vulnerabilities but they indicate that the administrator is not yet familiar with security hardening techniques.

Key Finding: Doing this passive reconnaissance exercise shows that these methods reveal security information without triggering intrusion detection systems. Organizations often leak critical details through headers, certificates, and publicly available information sources.

Blue Team: Defense & Hardening

Security Headers Implementation

2.1 Strict-Transport-Security (HSTS)

Below showcases what the Strict-Transport-Security header is supposed to look like. This shows that it should be included

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

Implementation: Set the HTTP Strict-Transport-Security header values through cloudflare's dashboard on which my domain name is purchased from.

2.2 Content-Security-Policy (CSP)

Including the Content-Security-Policy in the HTTP response headers allow the website administrator to control resources the user is allowed to load on the website!

This reduces the risk of cross-site scripting attacks because the resources that can be loaded is defined by the server. Not restricting resources leaves DaveHat.net highly vulnerable to client-side attacks and content manipulation.

Content-Security-Policy: default-src 'self'; img-src 'self' https://davehat.net; style-src 'self' 'unsafe-inline';

How is my site doing so far?

Here is the grade we receive from security headers after taking care of two things.

HTTP Security Headers Analysis

2.3 X-Frame-Options

Setting the X-Frame-Options header to the value of "SAMEORIGIN" tells the website that you do not want your website to be framed. Preventing a website from framing helps defend against clickjacking attacks.

2.4 Additional Security Headers

The headers Referrer-Policy and Permissions-Policy are the remaining ones on the list that have yet to be mitigated.

Implementation:

Final Result!!

Here is the grade we receive from security headers after checking all boxes.

HTTP Security Headers Analysis

Red Team vs Blue Team: Impact Summary

🔴 Red Team Findings

  • Strict-Transport-Security was not set
  • Content-Security-Policy was not set
  • X-Frame-Options was not set
  • Additional Headers were not set

🔵 Blue Team Mitigations

  • Set Strict-Transport-Security header
  • Set Content-Security-Policy header
  • Set X-Frame-Options header
  • Set the additional headers

Lessons Learned & Best Practices

Defense in Depth

No single security header can prevent all web application attacks. Implementing this comprehensive set of security headers will significantly reduce the attack surface and enhance the security of the application.

Configuration Management

Using the cloudflare dashboard on which this domain name is hosted from, requires me to manually set the Strict-Transport-Security headers and create the Content-Security-Policy, X-Frame-Options, and additional headers. This proves that configuration management is a necessary process when developing new technology to your organization's infrastructure.

Key Takeaway

Security Hardening: Implementing security hardening through the HTTPS headers will block the paths attackers may take to exploit other users on the website.

Sources & References