CVE-2023-36459

9.3 CRITICAL

📋 TL;DR

This vulnerability allows attackers to inject arbitrary HTML into Mastodon oEmbed preview cards by bypassing HTML sanitization. When users click on malicious links with crafted oEmbed data, cross-site scripting (XSS) payloads can execute in their browsers. All Mastodon instances running affected versions are vulnerable.

💻 Affected Systems

Products:
  • Mastodon
Versions: 1.3 through 3.5.8, 4.0.0 through 4.0.4, 4.1.0 through 4.1.2
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: All Mastodon instances with oEmbed previews enabled are vulnerable. The vulnerability is in the oEmbed HTML sanitization logic.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could steal user sessions, perform account takeovers, spread malware, or conduct phishing attacks by executing arbitrary JavaScript in victims' browsers.

🟠

Likely Case

Attackers will craft malicious links that, when shared, execute XSS payloads to steal session cookies or perform actions on behalf of logged-in users.

🟢

If Mitigated

With proper Content Security Policy (CSP) headers and other browser security controls, impact may be limited to specific browser contexts.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

The vulnerability is in public disclosure with technical details available. Crafting malicious oEmbed data requires understanding of the bypass technique but is straightforward for attackers.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.5.9, 4.0.5, or 4.1.3

Vendor Advisory: https://github.com/mastodon/mastodon/security/advisories/GHSA-xxxx-xxxx-xxxx

Restart Required: Yes

Instructions:

1. Backup your Mastodon instance. 2. Update to version 3.5.9, 4.0.5, or 4.1.3 using your package manager or from source. 3. Restart Mastodon services. 4. Verify the update was successful.

🔧 Temporary Workarounds

Disable oEmbed Previews

all

Temporarily disable oEmbed link previews to prevent exploitation while patching

Set `OEMBED_ENABLED=false` in Mastodon environment configuration

🧯 If You Can't Patch

  • Implement strict Content Security Policy (CSP) headers to limit XSS impact
  • Monitor for suspicious oEmbed data patterns and block malicious domains

🔍 How to Verify

Check if Vulnerable:

Check Mastodon version against affected ranges: 1.3-3.5.8, 4.0.0-4.0.4, 4.1.0-4.1.2

Check Version:

For Docker: `docker exec mastodon_web bundle exec rails runner 'puts Mastodon::Version.to_s'` | For source: check `Gemfile.lock` for mastodon version

Verify Fix Applied:

Verify version is 3.5.9, 4.0.5, or 4.1.3 or higher

📡 Detection & Monitoring

Log Indicators:

  • Unusual oEmbed requests with HTML/JavaScript payloads
  • Multiple failed oEmbed parsing attempts

Network Indicators:

  • Requests to known malicious domains in oEmbed data
  • Unusual outbound connections after clicking links

SIEM Query:

source="mastodon" AND (oembed OR preview) AND (html OR script OR javascript)

🔗 References

📤 Share & Export