Skip to content

Lack of media type verification of Activity Streams objects allows impersonation of remote accounts

High
renchap published GHSA-jhrq-qvrm-qr36 Feb 17, 2024

Package

Mastodon

Affected versions

<= v4.2.6

Patched versions

4.2.7, 4.1.15, 4.0.15, 3.5.19

Description

Summary

When fetching remote statuses, Mastodon doesn't check that the response from the remote server has a Content-Type header value of the Activity Streams media type, which allows a threat actor to upload a crafted Activity Streams document to a remote server and make a Mastodon server fetch it, if the remote server accepts arbitrary user uploads.

Details

Some federated server implementations allow their users to upload arbitrary documents, including JSON documents, as attachments to posts.

On the other hand, Mastodon's FetchRemoteStatusService did not check that the response from the remote server had a Content-Type header value of the Activity Streams media type (i.e. application/ld+json with a profile value of https://www.w3.org/ns/activitystreams, or application/activity+json). This implies that a Mastodon server can fetch a user-uploaded document on a remote server and accept it as an Activity Streams object unless it's otherwise malformed.

FetchRemoteStatusService#trustworthy_attribution? trusts the attributedTo property of a fetched object as long as the domain of the attributed actor is the same as the original request URI. Consequently, a threat actor with a low-privileged account on a remote server can upload an Activity Streams document with a crafted attributedTo property to the remote server and make a Mastodon server fetch it in order to impersonate another account on the same remote server.

FetchRemoteActorService doesn't check the Content-Type either. But it requires that the remote account is resolvable from a canonical acct: URI via WebFinger, so the service would reject a user-uploaded actor objects (unless the threat actor somehow manages to trick the remote server's well-known endpoint into resolving to the fake actor document).

JsonLdHelper#fetch_resource rejects the fetched resource if the id of the top-level node of the JSON-LD document doesn't match the original request URL, which increases complexity of the exploit as the threat actor needs an ability to predict the URI of the uploaded documents before uploading them or to edit the uploaded documents without changing the URI. For example, Misskey uses UUIDs in the URIs of uploaded documents so it's hard to impersonate accounts on a Misskey instance against Mastodon.

Impact

The vulnerability allows a threat actor to impersonate an account on a remote server that satisfies all of the following properties:

  1. Allows the attacker to register an account
  2. Accepts arbitrary user-uploaded documents and places them on the same domain as the ActivityPub actors
  3. Serves user-uploaded document in response to requests with an Accept header value of the Activity Streams media type

The vulnerability may also affect accounts on server implementations that don't normally serve arbitrary user-uploaded documents, in combination with a vulnerability of the other implementation like GHSA-9928-3cp5-93fm which can make the server serve arbitrary document,

Severity

High
8.5
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
Low
Integrity
High
Availability
None
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:N

CVE ID

CVE-2024-25623

Weaknesses

No CWEs

Credits