Skip to main content
Vulnerability Database/CVE-2024-51498

CVE-2024-51498: Cobalt Media Downloader XSS Vulnerability

CVE-2024-51498 is a cross-site scripting flaw in cobalt media downloader allowing malicious instances to serve javascript protocol links. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-51498 Overview

CVE-2024-51498 is a Cross-Site Scripting (XSS) vulnerability [CWE-79] in cobalt, an open-source media downloader. A malicious cobalt instance can serve download links using the javascript: protocol. When a user selects an item from the picker interface to download, the browser executes attacker-controlled JavaScript in the context of the cobalt web application.

The flaw was introduced in commit 66bac03e, partially mitigated in commit 97977efa through a Content Security Policy, and fully fixed in commit c4be1d3a, which ships in release 10.2.1. Correctly configured web instances were no longer vulnerable after the CSP mitigation.

Critical Impact

An operator of a malicious cobalt instance can execute arbitrary JavaScript in a visiting user's browser session, leading to session theft, credential capture, or further client-side attacks.

Affected Products

  • cobalt media downloader (web frontend) prior to release 10.2.1
  • Self-hosted cobalt instances introduced from commit 66bac03e onward
  • Deployments without a configured Content-Security-Policy header

Discovery Timeline

  • 2024-11-05 - CVE-2024-51498 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-51498

Vulnerability Analysis

The vulnerability resides in the client-side download handler of the cobalt web frontend. The openURL function in web/src/lib/download.ts passed any URL string returned by a cobalt instance directly to window.open. Because window.open honors the javascript: scheme, a malicious server could return a crafted URL that executes JavaScript in the origin of the cobalt web application.

The attack requires user interaction: the victim must initiate a download and then click an item in the picker dialog. The picker dialog itself was added in commit 66bac03e, which is when the issue first became reachable. Since cobalt is designed to be self-hostable, trust in the backend instance is not implicit, and a hostile operator can weaponize their deployment against users who paste links into it.

Root Cause

The root cause is missing URL scheme validation before invoking window.open. The frontend assumed the backend would only return http: or https: URLs and did not enforce this assumption. Combined with the absence of a Content-Security-Policy response header on the hosted web assets, there was no defense-in-depth to block inline script execution originating from javascript: URLs.

Attack Vector

An attacker who controls a cobalt instance returns a picker response containing an item whose download URL begins with javascript:. When the victim clicks the item, the browser evaluates the payload in the cobalt origin, giving the attacker access to the DOM, local storage, and any cookies scoped to the site.

typescript
// Fix in web/src/lib/download.ts (commit c4be1d3a)
export const openURL = (url: string) => {
    if (!['http:', 'https:'].includes(new URL(url).protocol)) {
        return alert('error: invalid url!');
    }

    const open = window.open(url, "_blank");

    /* if new tab got blocked by user agent, show a saving dialog */
};

Source: GitHub Cobalt Commit c4be1d3

typescript
// CSP mitigation in web/src/routes/_headers/+server.ts (commit 97977efa)
export async function GET() {
    const CSP = [
        "default-src 'none'",
        "script-src 'self' challenges.cloudflare.com",
        "frame-src challenges.cloudflare.com",
    ]

    const _headers = {
        "/*": {
            "Cross-Origin-Opener-Policy": "same-origin",
            "Cross-Origin-Embedder-Policy": "require-corp",
            "Content-Security-Policy": CSP.join("; "),
        }
    }
}

Source: GitHub Cobalt Commit 97977ef

Detection Methods for CVE-2024-51498

Indicators of Compromise

  • Picker responses from a cobalt backend containing download URLs that begin with javascript:, data:, or other non-HTTP schemes.
  • Browser console errors or alert('error: invalid url!') dialogs on patched clients, indicating a server attempted to deliver a non-HTTPS link.
  • Outbound requests to unexpected domains immediately after a cobalt download interaction.

Detection Strategies

  • Inspect network traffic from the cobalt frontend for JSON responses containing "url" fields whose values do not start with http:// or https://.
  • Review browser Content-Security-Policy violation reports from users of self-hosted cobalt instances.
  • For organizations hosting cobalt internally, pin the deployed version to 10.2.1 or later and alert on drift.

Monitoring Recommendations

  • Enable CSP reporting (report-to / report-uri) on cobalt deployments to surface blocked script attempts.
  • Monitor cobalt backend logs for anomalous picker payload generation if operating a shared instance.
  • Track client-side JavaScript errors through browser telemetry to catch exploitation attempts against unpatched builds.

How to Mitigate CVE-2024-51498

Immediate Actions Required

  • Upgrade self-hosted cobalt deployments to release 10.2.1 or later, which includes commit c4be1d3a.
  • Audit any cobalt instance URL users have interacted with, and clear browser session data for untrusted instances.
  • Advise users to only submit links to cobalt instances operated by trusted parties.

Patch Information

The full fix is included in cobalt release 10.2.1 via commit c4be1d3a, which validates URL protocols before calling window.open. An earlier mitigation in commit 97977efa added a Content-Security-Policy header that neutralized the issue on correctly configured web instances. See the GitHub Security Advisory GHSA-cm4c-v4cm-3735 for the official advisory.

Workarounds

  • If upgrading is not possible, enable a strict Content-Security-Policy header on the cobalt web host that restricts script-src to 'self'.
  • Set default-src 'none' and explicitly allow only required origins, mirroring the configuration shipped in commit 97977efa.
  • Place the cobalt frontend behind a reverse proxy that injects the CSP header if the application layer cannot be modified.
bash
# Example reverse-proxy CSP header for cobalt (nginx)
add_header Content-Security-Policy "default-src 'none'; script-src 'self' challenges.cloudflare.com; frame-src challenges.cloudflare.com" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Embedder-Policy "require-corp" always;

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.