/

CVE-2026-47389

Severity:

HIGH RISK

(8.6)

SSRF via IPv4-mapped IPv6 (CWE-918) in Mastodon

CVE-2026-47389

Deferred

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-184, CWE-200, CWE-918

Impact:

Access to internal network resources and sensitive metadata via SSRF

Severity:

HIGH RISK

(8.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Mastodon instances running on Ruby versions older than 3.4 may misclassify certain IPv4-mapped IPv6 addresses as public, allowing outbound connections to internal endpoints.

If an attacker controls DNS records for a domain Mastodon fetches, they can direct Mastodon's HTTP client to loopback or cloud-metadata services, potentially exposing sensitive data and enabling SSRF attacks.

Affected context

This vulnerability appears in Mastodon's outbound HTTP request handling when resolving hostnames to IP addresses on Ruby runtimes older than 3.4.

It specifically affects deployments that rely on PrivateAddressCheck.private_address? to block private or loopback network access but run on Ruby versions where IPv4-mapped IPv6 addresses (::ffff:a.b.c.d) are not correctly flagged as private.

The risk manifests when Mastodon performs remote fetches (e.g., ActivityPub interactions, media retrieval, URL previews) to domains whose DNS can be influenced by an attacker.

Exploit preconditions

  • Attack surface: Mastodon's outbound HTTP client used for fetching remote URLs, ActivityPub resources, media, or metadata.
  • Required access: Ability to control DNS for a domain that Mastodon will contact (e.g., hosting a remote instance, controlling URLs embedded in content, or influencing link previews).
  • Trigger point: Mastodon initiates an HTTP request to an attacker-controlled hostname, and DNS resolution returns an AAAA record with an IPv4-mapped IPv6 address pointing to a private or loopback IPv4 target.
  • Why exploitation is possible: On Ruby versions older than 3.4, PrivateAddressCheck.private_address? incorrectly returns false for some IPv4-mapped IPv6 addresses, causing Mastodon to treat internal endpoints (like 127.0.0.1 or 169.254.169.254) as allowed and open real TCP connections.

Why this happens

The underlying issue is an incomplete validation of IP address categories when filtering outbound connections, mapped to CWE-918: Server-Side Request Forgery, CWE-184: Incomplete List of Validation Rules, and CWE-200: Exposure of Sensitive Information.

Mastodon relies on PrivateAddressCheck.private_address? to prevent requests to private and loopback networks, but on Ruby versions older than 3.4 the check does not fully account for IPv4-mapped IPv6 representations (::ffff:a.b.c.d).

As a result, addresses that should be classified as private (such as RFC1918 ranges, loopback, and link-local metadata services) can bypass filtering when encoded as mapped IPv6, leading the application to perform unintended internal network requests on behalf of an attacker.

Potential impact

  • Mastodon may fetch from loopback services (e.g., 127.0.0.1), exposing internal admin interfaces or debugging endpoints.
  • An attacker could reach cloud instance metadata services (e.g., 169.254.169.254), potentially retrieving credentials and configuration data.
  • Internal APIs or database proxies accessible only on private IP ranges could be queried indirectly through Mastodon.
  • Mastodon logs and responses could leak sensitive information obtained from internal endpoints.
  • SSRF access may serve as a pivot to escalate impact, depending on what internal services accept HTTP requests.

General mitigation guidance

Effective mitigation focuses on robust network egress controls and strict IP validation prior to making outbound requests.

Common defensive patterns include:

  • Implementing comprehensive IP classification that correctly handles IPv4, IPv6, and IPv4-mapped IPv6 forms, ensuring private, loopback, and link-local addresses are consistently blocked.
  • Introducing an allowlist-based policy for outbound HTTP destinations, limiting connections to explicitly trusted domains or networks.
  • Using network-level egress filtering and metadata service hardening so application servers cannot reach sensitive internal addresses by default.
  • Decoupling user-controlled URLs from application-level fetches where possible, or proxying them through tightly controlled intermediaries.
  • Applying least-privilege principles to services that might be reachable from the application layer, ensuring that even if a request is made, it exposes minimal information.

How teams detect issues like this

High-level detection can combine code analysis, configuration review, and runtime monitoring:

  • Use static analysis or code review to look for IP filtering logic that does not normalize or validate IPv4-mapped IPv6 addresses and relies on incomplete "private address" checks.
  • Review outbound request code paths that accept hostnames or URLs influenced by external actors, ensuring they pass through central validation and filtering components.
  • Monitor logs for unusual outbound requests to loopback, link-local, or RFC1918 ranges originating from the Mastodon application.
  • Implement security policies that flag or block DNS records resolving to internal IP ranges, including IPv4-mapped IPv6 addresses, when used in application traffic.
  • Optional: employ automated security scanners or SSRF-focused testing tools to exercise URL-fetch features and detect unexpected internal connectivity.

Sources

SourceLink
github.comgithub.com/mastodon/mastodon/security/advisories/GHSA-xx55-4rrg-8xg6

Frequently asked

questions

It can reach any internal endpoint that becomes accessible via an IPv4-mapped IPv6 address and is not properly classified as private, including loopback, RFC1918 ranges, and some link-local services, depending on network topology and Ruby behavior.

An attacker must control DNS records for a domain Mastodon contacts, such as by operating a remote instance, controlling URLs embedded in content, or manipulating hostnames used in outbound fetches. They do not need shell access to the Mastodon server.

The most robust pattern is to normalize and validate all resolved IP addresses against a strict set of rules that cover IPv4, IPv6, and mapped forms, combined with allowlist-based outbound connection policies and network egress restrictions to sensitive internal ranges.

Design outbound HTTP features so that they never directly fetch arbitrary user-controlled URLs, centralize IP and hostname validation, enforce domain allowlists, and rely on infrastructure-level protections (such as firewalls and metadata service hardening) to make sensitive internal endpoints unreachable from application servers.

Find out what's already
exploitable in your codebase.