Blog | G5 Cyber Security

HTTPS Embedding Security: Prevent Data Theft

TL;DR

An attacker can steal information from your HTTPS page if they embed it in a malicious website using an <iframe> or similar technique. This is because the browser still loads your content, even within another site. The key to preventing this is using Content Security Policy (CSP) and Frame Ancestors headers on your server.

How Embedding Works & Why It’s a Risk

Imagine you have a secure banking page (https://yourbank.com). An attacker creates a fake website (http://evil.example.com) and embeds your banking page within it using an <iframe> tag:

<iframe src="https://yourbank.com" width="800" height="600"></iframe>

Users visiting http://evil.example.com will see your banking page loaded inside the attacker’s site. They might think they are on your legitimate website, and enter their login details – which are then sent to the attacker.

Steps to Protect Your HTTPS Page

  1. Understand Content Security Policy (CSP)
  • Implement Frame Ancestors Header
  • Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Frame-Ancestors "yourbank.com anotherdomain.com"
  • Configure CSP for your web server
  • Header always set Content-Security-Policy "frame-ancestors 'self' yourbank.com;"
    add_header Content-Security-Policy "frame-ancestors 'self' yourbank.com;";
  • Test Your Configuration
  • Regularly Review Your CSP
  • Additional Considerations

    Exit mobile version