/

CVE-2026-22245

Severity:

HIGH RISK

(7.5)

SSRF in Mastodon Outbound Request Filtering

CVE-2026-22245

Analyzed

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Unauthorized Access to Internal Services via SSRF

Severity:

HIGH RISK

(7.5)

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's outbound HTTP request filtering missed certain IP ranges that can route to local or loopback addresses, creating a server-side request forgery (SSRF) condition.

Under specific network configurations, an attacker who controls or influences user-provided domains can cause Mastodon to send HTTP requests to internal services that are normally inaccessible from the public internet.

Affected context

This vulnerability affects Mastodon deployments that make outbound HTTP requests to user-controlled or user-specified domains (for example, during federation, preview fetching, or remote resource retrieval).

Mastodon attempts to block connections to private and loopback IP ranges, but the denylist did not cover all IP address ranges and encodings that can be used to reach local hosts.

In environments where Mastodon has network-level access to internal services (e.g., databases, admin panels, metadata services, internal APIs), this gap in filtering can expose those services through Mastodon's outbound request capabilities.

Exploit preconditions

  • Attack surface: Any Mastodon functionality that performs HTTP(S) requests to domains or URLs derived from user input or remote instances.
  • Required access: Ability to submit or control URLs or domains that Mastodon will fetch (e.g., controlling a remote instance, profile links, media URLs, or similar federation inputs).
  • Network context: Mastodon server must have network reachability to internal or loopback services (such as 127.0.0.1, 10.0.0.0/8, 192.168.0.0/16, or cloud metadata endpoints) through the overlooked IP ranges.
  • Why exploitation is possible: The IP filtering logic relied on an incomplete set of disallowed ranges, allowing crafted addresses that resolve to internal targets to pass validation and be used for outbound connections.

Why this happens

The root cause is an incomplete implementation of network egress restrictions in Mastodon's SSRF protection logic.

To prevent "confused deputy" issues, Mastodon attempts to block requests to private or loopback address ranges; however, some routable IP blocks and representations that can reach internal resources were omitted from the denylist.

This aligns with CWE-918: Server-Side Request Forgery (SSRF), where a server is tricked into making requests to unintended destinations because validation of target addresses, ranges, or resolution behavior is incomplete or overly permissive.

Potential impact

  • Mastodon may disclose HTTP responses from internal services that are not exposed publicly.
  • Attackers could access internal admin panels or configuration endpoints reachable only from the Mastodon host's network.
  • Internal APIs or microservices might be queried, potentially leaking data or triggering state changes.
  • Cloud or infrastructure metadata services (if reachable) could be queried, which can expose sensitive instance metadata or credentials.
  • Defense-in-depth assumptions about network segmentation and "internal only" endpoints can be weakened.

General mitigation guidance

Mitigation generally focuses on hardening outbound network controls and making SSRF protection comprehensive and default-deny.

Common defensive patterns include:

  • Implementing a strict allowlist for outbound destinations or IP ranges, especially for features that must contact remote servers.
  • Centralizing IP and hostname validation, ensuring it covers:
  • All private and loopback ranges
  • Link-local and metadata service ranges
  • IPv6 equivalents and special-use addresses
  • Multiple resolution passes (A/AAAA, CNAME chains) as needed
  • Performing post-DNS resolution checks on the final IP address and rejecting any that fall within disallowed ranges.
  • Using application-level network policies (e.g., egress firewall or service mesh policies) to block access from Mastodon to sensitive internal services by default.
  • Running Mastodon in a network segment with minimal necessary access, keeping high-value internal services on separate, non-routable segments.

How teams detect issues like this

Detection typically involves both code-level and infrastructure-level approaches:

  • Static analysis and code review:
  • Flag any code paths that perform HTTP requests to user-influenced URLs without routing through a common validation function.
  • Review IP filtering utilities for completeness of private, loopback, and special-use ranges, including IPv6 and edge cases.
  • Look for bypass patterns such as integer-based IP representations, uncommon encodings, or DNS-based indirections that may not be rechecked.
  • Dynamic and operational monitoring:
  • Monitor Mastodon's outbound traffic for connections to internal CIDRs or unexpected targets.
  • Use network telemetry or firewall logs to alert on egress from the Mastodon host to internal or metadata networks.
  • Security testing:
  • Include SSRF test cases in regular penetration tests and CI-based security checks, focusing on multiple IP formats and DNS tricks.
  • Automated security scanners or HTTP client wrappers can be integrated into the codebase to enforce consistent SSRF protections across all outbound requests.

Sources

SourceLink
github.comgithub.com/mastodon/mastodon/commit/0f4e8a6240b5af1f2c3f34d2793d8610c6ef2aca
github.comgithub.com/mastodon/mastodon/commit/17022907866710a72a1b1fc0a5ce9538bad1b4c3
github.comgithub.com/mastodon/mastodon/commit/71ae4cf2cf5138ccdda64b1b1d665849b688686d
github.comgithub.com/mastodon/mastodon/security/advisories/GHSA-xfrj-c749-jxxq

Frequently asked

questions

Yes. An attacker who can supply or influence URLs that Mastodon fetches remotely can attempt to exploit this issue, provided the server has network access to internal resources via the overlooked IP ranges.

The attacker generally needs the ability to cause Mastodon to perform outbound requests to attacker-controlled or attacker-chosen domains or URLs.

This may be achievable through normal federation behavior or other features where user input results in remote resource fetching.

The most robust pattern is to enforce a centralized, strict allowlist or comprehensive denylist on all outbound HTTP requests, validating the final resolved IP address (including CNAME chains) against a well-maintained set of safe networks, and blocking local, private, and metadata address spaces by default.

To prevent recurrences, treat all user-influenced URLs as untrusted, route all outbound requests through a shared, audited network client, apply layered defenses (application-level IP checks plus network-level egress controls), and incorporate SSRF-specific tests and static analysis rules into regular development and review workflows.

Find out what's already
exploitable in your codebase.