← Back to Safety Checks

Iframe Usage

Medium Severity

What This Check Measures

This check detects the presence of <iframe> elements on the page. Iframes embed external content from other websites, which can introduce security risks if the embedded sources are not trustworthy.

Why It Matters

How Data Is Obtained

Source File

src/checks/safety.check.js

Function

SafetyCheck.analyze(url)

Input

response.data — The HTML content returned by the target URL

Detection Logic

// Count iframe elements using regex
const iframes = response.data?.match(/<iframe/gi) || [];

checks.push({
  name: 'Iframe Usage',
  status: iframes.length > 0 ? 'warn' : 'pass',
  description: iframes.length > 0 
    ? `${iframes.length} iframes detected - verify they're from trusted sources` 
    : 'No iframes detected',
  severity: 'medium'
});

Libraries

  • axios — Fetches the page HTML
  • Native JavaScript String.match() with regex

Status Values

Status Condition Meaning
pass No iframes found Page doesn't embed external content via iframes. Lower risk.
warn 1+ iframes detected External content is embedded. Should verify sources are trustworthy.

Severity: Medium

This check has medium severity because:

Common Legitimate Iframe Uses

  • YouTube/Vimeo video embeds
  • Google Maps integration
  • Social media widgets (Twitter, Facebook)
  • Payment forms (Stripe, PayPal)
  • Chat widgets (Intercom, Zendesk)
  • Analytics dashboards

Security Best Practices

Securing Iframes

  • sandbox attribute — Restrict iframe capabilities
  • Only trusted sources — Only embed content from known, reputable domains
  • X-Frame-Options header — Prevent your site from being iframed (see Security section)
  • CSP frame-ancestors — Modern alternative to X-Frame-Options
  • referrerpolicy — Control what referrer info is sent

Impact on Category Score

As a medium severity check with warn status, iframe detection has a moderate negative impact on the Safety & Threats score. A pass (no iframes) contributes positively.