Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-46340

CVE-2025-46340: Misskey Social Platform XSS Vulnerability

CVE-2025-46340 is an XSS vulnerability in Misskey that allows CSS injection through URL preview components, enabling credential theft attacks. This article covers technical details, affected versions, impact, and mitigation.

Published:

CVE-2025-46340 Overview

CVE-2025-46340 is a CSS injection vulnerability in Misskey, an open source federated social media platform. The flaw exists in the UrlPreviewService and MkUrlPreview components, which fail to properly validate and escape URLs before applying them as a background-image CSS property. Attackers can craft malicious URLs that inject arbitrary CSS into the preview element rendered in other users' clients. The issue affects versions from 12.0.0 up to but not including 2025.4.1, and is classified under [CWE-20] Improper Input Validation.

Critical Impact

Attackers can inject arbitrary CSS to create fake error messages, deceive users into disclosing credentials, and de-anonymize users through remote resource loading.

Affected Products

  • Misskey versions 12.0.0 through 2025.4.0
  • UrlPreviewService backend component
  • MkUrlPreview frontend component

Discovery Timeline

  • 2025-05-05 - CVE-2025-46340 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-46340

Vulnerability Analysis

The vulnerability originates from two coordinated flaws in Misskey's URL preview pipeline. The backend UrlPreviewService.wrap function checks whether a URL uses http or https. If the protocol differs, the function returns the original URL unchanged instead of routing it through the media proxy. The frontend MkUrlPreview component then interpolates that URL directly into a CSS background-image property without escaping special characters. Attackers combine these behaviors to break out of the CSS url() context and inject arbitrary style declarations into the preview element.

Root Cause

The root cause is missing input validation and output encoding. The wrap function's protocol-based fallback allowed non-standard URIs to pass through untouched. Simultaneously, the frontend concatenated attacker-controlled strings into a CSS property without escaping quotes, parentheses, or semicolons, enabling style injection.

Attack Vector

An attacker publishes a note containing a specially crafted URL. When another user's client renders the URL preview, the malicious CSS is applied to the DOM. The injected styles can position overlays, load external resources that leak the viewer's IP address, or render a spoofed error message that solicits credentials.

typescript
// Patched code in packages/backend/src/server/web/UrlPreviewService.ts
@bindThis
private wrap(url?: string | null): string | null {
    return url != null
-       ? url.match(/^https?:\/\//)
-           ? `${this.config.mediaProxy}/preview.webp?${query({
-               url,
-               preview: '1',
-           })}`
-           : url
+       ? `${this.config.mediaProxy}/preview.webp?${query({
+           url,
+           preview: '1',
+       })}`
        : null;
}

Source: Misskey commit d10fdfe

The patch removes the protocol-based fallback so every URL is routed through the media proxy, preventing attacker-controlled schemes from reaching the CSS context.

Detection Methods for CVE-2025-46340

Indicators of Compromise

  • URLs in notes or profile fields using protocols other than http or https, such as javascript:, data:, or crafted schemes containing quote and parenthesis characters.
  • Outbound requests from client browsers to attacker-controlled domains that correlate with viewing a specific note.
  • Preview elements exhibiting unexpected styling, positioning, or overlay behavior in rendered timelines.

Detection Strategies

  • Inspect notes and metadata for URLs failing standard https?:// protocol validation.
  • Review server logs for requests to UrlPreviewService endpoints containing unusual URI schemes or CSS control characters like ', ", ), or ;.
  • Monitor the running Misskey version and confirm all instances are at 2025.4.1 or later.

Monitoring Recommendations

  • Ingest Misskey application and web server logs into a centralized analytics platform for URL pattern analysis.
  • Alert on client-side referrer requests originating from Misskey preview components toward unknown external hosts.
  • Track Content Security Policy (CSP) violation reports for style-src and img-src directives.

How to Mitigate CVE-2025-46340

Immediate Actions Required

  • Upgrade all Misskey instances to version 2025.4.1 or later, which contains the patch in commit d10fdfe.
  • Audit federated content and remove notes containing URLs with non-standard protocols pending upgrade.
  • Notify users about phishing risk from spoofed error messages appearing in URL previews.

Patch Information

The fix landed in Misskey 2025.4.1. The patch removes the protocol-based fallback in UrlPreviewService.wrap so every URL is routed through the media proxy, and it introduces a maybeMakeRelative helper for safer URL handling. See the GitHub Security Advisory GHSA-3p2w-xmv5-jm95 for full details.

Workarounds

  • Disable URL previews in the Misskey instance configuration until the patched version is deployed.
  • Deploy a strict Content Security Policy that forbids inline styles and restricts background-image sources to trusted domains.
  • Filter federated content at the reverse proxy layer to reject notes containing URLs with non-http(s) schemes.
bash
# Upgrade Misskey to patched version
git fetch --tags
git checkout 2025.4.1
pnpm install
pnpm run build
pnpm run migrate
systemctl restart misskey

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

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.