Permission Bypass in Explicit Media Endpoints leading to Private Message Leakage
The explicit media scanning endpoints did not check channel permissions, so an attacker could request message objects from channels they were not authorised to access. By obtaining message IDs from a separate endpoint, they could read private message contents.
- Accepted in 5 hours
- Fixed in 2 days
- Disclosed after 4 days
Summary by customer
This vulnerability allowed viewing message contents from messages containing an embed or media attachment without authorization. The message and channel IDs were required to request an explicit media scan; however, knowledge of both IDs is not seen as a severity-lowering factor.
Summary by darkerink
A broken access control vulnerability was discovered in the Explicit Media scanning endpoints. By using said endpoints, an attacker could bypass VIEW_CHANNEL and READ_MESSAGE_HISTORY permissions to receive message objects from channels, DM channels, or threads they were not authorized to access.
The vulnerability relied on a separate core part to receive message IDs. By polling /guilds/:guidlId/channels, attackers would be able to receive last_message_id's, which was updated live as users sent new messages.
Once the attacker has the message IDs they want, they could send a PATCH request to /messages/explicit-media with a body of
{
"messages": [
{
"message_id": "...",
"channel_id": "..."
}
]
}
Which sent MESSAGE_UPDATE events to themselves via the gateway.
Context
Discord's Explicit Media scanning endpoints are part of the platform's content moderation tooling. They accept a list of message identifiers and channel identifiers and return the corresponding message objects so that media attached to those messages can be scanned.
Access to messages on Discord is governed by channel permissions. VIEW_CHANNEL controls whether a user can see a channel at all, and READ_MESSAGE_HISTORY controls whether they can read messages already posted there. Direct messages and threads have their own access rules.
Setup
The report does not describe any special accounts, roles, tools or versions. The only precondition it names is knowledge of two identifiers: a message ID and the channel ID it belongs to. The customer summary explicitly states that knowing both IDs is not treated as a factor that lowers severity.
Finding it
The researcher identified a broken access control issue in the Explicit Media scanning endpoints. The endpoints accepted message and channel identifiers and returned message objects without checking whether the caller held VIEW_CHANNEL or READ_MESSAGE_HISTORY on the relevant channel. That meant a caller could receive message objects from channels, DM channels or threads they were not authorised to access.
The endpoints on their own were not enough: they required message IDs as input. The researcher therefore treated the vulnerability as depending on a separate core component to obtain those IDs, and went looking for a place where message identifiers leaked.
Exploitation
Step 1: Harvest message IDs from the guild channel listing
The researcher polled the guild channel listing endpoint:
/guilds/:guidlId/channels
This returned channel objects containing last_message_id values. Those values were updated live as users sent new messages, so polling the endpoint produced a stream of fresh message IDs for channels the attacker could enumerate. The report does not describe how the attacker obtained the guild ID or which guilds were reachable.
Step 2: Submit the IDs to the Explicit Media endpoint
With message IDs in hand, the attacker sent a PATCH request to the Explicit Media endpoint with the following body:
{
"messages": [
{
"message_id": "...",
"channel_id": "..."
}
]
}
Each entry pairs a message_id with the channel_id it belongs to. The endpoint processed the list and sent MESSAGE_UPDATE events to the attacker via the gateway.
Step 3: Receive the content through the gateway
The endpoint sent MESSAGE_UPDATE events to the attacker via the gateway. The attacker's own client therefore received the message objects as gateway events, giving them the contents of messages, including any embed or media attachment, from channels, DM channels or threads they were not authorised to access.
Root cause
The Explicit Media endpoints performed no authorisation check against the caller's permissions on the channel referenced in the request. They trusted the supplied channel_id and message_id pair and returned the message object regardless of whether the caller held VIEW_CHANNEL or READ_MESSAGE_HISTORY there.
The customer summary rejects that assumption: knowledge of the message and channel IDs is not a severity-lowering factor. The last_message_id values in the guild channel listing supplied the message IDs.
Impact
An attacker could read the contents of messages, including embeds and media attachments, from channels, DM channels and threads they were not authorised to access. The conditions are that the attacker knows the message ID and the corresponding channel ID, which the guild channel listing provided for guild channels.
The report was rated high severity and paid a bounty of 2,000 USD.
Fix
Variants to test
- Other bulk lookup endpoints that accept a list of object identifiers, such as message, attachment or media scanning APIs. A positive result is a response containing objects from a channel the test account cannot open in the client.
- Endpoints that emit results as gateway events or websocket pushes rather than in the HTTP response. A positive result is an event arriving for a channel the account is not subscribed to or cannot view.
- Channel listing endpoints that expose
last_message_idor similar live counters for channels the caller cannot read. A positive result is a fresh identifier for a channel the account has no access to. - The same identifier-pair pattern against threads and DM channels, where permission models differ from guild channels. A positive result is a message object from a thread or DM the account is not part of.
Hunting notes
Signals during recon include endpoints that take object IDs in bulk, endpoints whose names suggest scanning, moderation or media processing, and any listing endpoint that returns live identifiers such as last_message_id for objects the caller cannot otherwise reach.
The researcher chained the identifier leak to the unauthorised lookup, with content arriving as a MESSAGE_UPDATE event. The customer summary states that knowledge of the message and channel IDs does not lower severity.
What happened, in plain words
Discord is a chat platform. People talk in servers (groups of channels), in direct messages (DMs, one-to-one or small group chats), and in threads (side conversations attached to a message). Every message lives in a channel, and every channel has rules about who may see it.
Discord also runs a feature called Explicit Media scanning. It is part of the platform's content moderation tooling: it takes a list of message identifiers and channel identifiers and hands back the matching messages, so that media attached to them can be checked.
The researcher darkerink found that this tool did not actually check that. If you knew a message's ID and the ID of the channel it sat in, you could ask the scanning tool for that message and it would give it to you, even if you had no permission to open that channel at all. The contents came back to you as an event pushed through Discord's live connection, called the gateway.
To get the message IDs in the first place, the researcher used a second, ordinary endpoint that lists a server's channels and reports the ID of the most recent message in each one. That value updates live as people type, so polling it produced a steady supply of fresh message IDs.
The report was rated high severity and paid a bounty of 2,000 USD.
Background: the pieces involved
Before walking through the steps, here are the concepts the report leans on.
API. An API (Application Programming Interface) is the set of addresses a program can send requests to in order to read or change something on a server. Think of a restaurant: the menu is the list of things you can order, and the waiter carries your order to the kitchen. The API is the menu plus the waiter. When you use Discord's website or app, it is quietly sending API requests on your behalf.
Endpoint. One specific address in that API. /guilds/:guildId/channels is an endpoint: a fixed path with a placeholder (:guildId) where a real identifier goes.
HTTP method. Every API request carries a verb saying what kind of action it is. GET means read something. PATCH means partially update something. The report uses both.
Identifier (ID). A long string of characters that uniquely names one object, like a barcode on a product. A message has a message ID, a channel has a channel ID, a server (called a guild) has a guild ID.
Guild. Discord's internal name for a server, the container that holds a set of channels.
Permissions. Rules attached to a channel saying what each user may do there. Two matter here:
VIEW_CHANNEL: may this user see the channel exists and open it at all?READ_MESSAGE_HISTORY: may this user read messages that were already posted there?
If you lack VIEW_CHANNEL, the channel should be invisible to you. If you lack READ_MESSAGE_HISTORY, you may see the channel but not scroll back through it.
Broken access control. The vulnerability class in this report. Access control is the part of a system that decides who is allowed to do what. It is broken when the system performs the action without properly asking that question. The everyday comparison: a hotel gives every guest a key card for their own room, and the door lock checks the card. If the lock opens for any card at all, the lock is broken even though the cards look fine. Here, the Explicit Media endpoint was the lock that opened for anyone.
Gateway. Discord's live connection. Instead of your app asking the server "anything new?" every second, the server pushes events down an always-open connection. An event is a small message saying something happened, for example MESSAGE_UPDATE, which tells the client that a message changed and includes the message data.
Message object. The structured record of a message: its text, who sent it, when, and any embeds or attachments. An embed is a rich preview card, for example a link that expands into a title, description and image. A media attachment is an uploaded file such as an image or video.
Polling. Asking the same endpoint over and over on a schedule to see what changed, like checking the letterbox every few minutes rather than waiting for the postman to ring.
Context
Discord's Explicit Media scanning endpoints are part of the platform's content moderation tooling. They accept a list of message identifiers and channel identifiers and return the corresponding message objects so that media attached to those messages can be scanned. The endpoints are meant to be used on messages the caller is already entitled to see.
Access to messages on Discord is governed by channel permissions. VIEW_CHANNEL controls whether a user can see a channel at all, and READ_MESSAGE_HISTORY controls whether they can read messages already posted there. Direct messages and threads have their own access rules.
Setup
The report does not describe any special accounts, roles, tools or versions. The only precondition it names is knowledge of two identifiers: a message ID and the channel ID it belongs to. The customer summary explicitly states that knowing both IDs is not treated as a factor that lowers severity.
The customer summary states that knowing both IDs is not treated as a factor that lowers severity.
Finding it
The researcher identified a broken access control issue in the Explicit Media scanning endpoints. The endpoints accepted message and channel identifiers and returned message objects without checking whether the caller held VIEW_CHANNEL or READ_MESSAGE_HISTORY on the relevant channel. That meant a caller could receive message objects from channels, DM channels or threads they were not authorised to access.
The endpoints on their own were not enough: they required message IDs as input. The researcher therefore treated the vulnerability as depending on a separate core component to obtain those IDs, and went looking for a place where message identifiers leaked.
Exploitation
Step 1: Harvest message IDs from the guild channel listing
The researcher polled the guild channel listing endpoint:
/guilds/:guidlId/channels
Line by line:
/guilds/is the part of the path that refers to servers (guilds).:guidlIdis a placeholder where a real guild ID goes. The spelling in the report is exactly as written there./channelsasks for the list of channels inside that guild.
This returned channel objects containing last_message_id values. Those values were updated live as users sent new messages, so polling the endpoint produced a stream of fresh message IDs for channels the attacker could enumerate. The report does not describe how the attacker obtained the guild ID or which guilds were reachable.
Why this step: the scanning endpoint needs a message ID, and this listing hands one out for every channel, kept current as people chat. Polling it repeatedly, like checking the letterbox every few minutes, means the attacker always has a recent message ID to try.
Step 2: Submit the IDs to the Explicit Media endpoint
With message IDs in hand, the attacker sent a PATCH request to the Explicit Media endpoint with the following body:
{
"messages": [
{
"message_id": "...",
"channel_id": "..."
}
]
}
Line by line:
- The outer braces
{and}wrap a single JSON object, the body of the request. JSON is a plain text format for structured data, readable by both people and programs. "messages"is the field name. Its value is a list, shown by the square brackets[and], so several entries could be sent at once.- Inside the list sits one entry, itself wrapped in braces: a pair of fields.
"message_id": "..."is the ID of the message being asked for. The...stands for the real value."channel_id": "..."is the ID of the channel that message lives in.
Each entry pairs a message_id with the channel_id it belongs to. The endpoint processed the list and sent MESSAGE_UPDATE events to the attacker via the gateway.
Step 3: Receive the content through the gateway
The endpoint sent MESSAGE_UPDATE events to the attacker via the gateway. The attacker's own client therefore received the message objects as gateway events, giving them the contents of messages, including any embed or media attachment, from channels, DM channels or threads they were not authorised to access.
The endpoint sent MESSAGE_UPDATE events to the attacker via the gateway, giving them message contents including embeds and media attachments.
Root cause
The Explicit Media endpoints performed no authorisation check against the caller's permissions on the channel referenced in the request. They trusted the supplied channel_id and message_id pair and returned the message object regardless of whether the caller held VIEW_CHANNEL or READ_MESSAGE_HISTORY there.
The customer summary rejects that assumption: knowledge of the message and channel IDs is not a severity-lowering factor. The last_message_id values in the guild channel listing supplied the message IDs.
Put simply: the endpoint treated "you named this message" as "you may read this message". Those are different things, and the gap between them is the bug.
Impact
An attacker could read the contents of messages, including embeds and media attachments, from channels, DM channels and threads they were not authorised to access. The conditions are that the attacker knows the message ID and the corresponding channel ID, which the guild channel listing provided for guild channels.
Fix
In hotel terms: the door lock must actually read the card and compare it with the room number, every time, for every kind of room.
Variants to test
- Other bulk lookup endpoints that accept a list of object identifiers, such as message, attachment or media scanning APIs. A positive result is a response containing objects from a channel the test account cannot open in the client.
- Endpoints that emit results as gateway events or websocket pushes rather than in the HTTP response. A positive result is an event arriving for a channel the account is not subscribed to or cannot view.
- Channel listing endpoints that expose
last_message_idor similar live counters for channels the caller cannot read. A positive result is a fresh identifier for a channel the account has no access to. - The same identifier-pair pattern against threads and DM channels, where permission models differ from guild channels. A positive result is a message object from a thread or DM the account is not part of.
Hunting notes
Signals during recon include endpoints that take object IDs in bulk, endpoints whose names suggest scanning, moderation or media processing, and any listing endpoint that returns live identifiers such as last_message_id for objects the caller cannot otherwise reach.
The researcher chained the identifier leak to the unauthorised lookup, with content arriving as a MESSAGE_UPDATE event. The customer summary states that knowledge of the message and channel IDs does not lower severity.
Glossary
- API: the set of addresses and rules a program uses to talk to a server, like a menu plus a waiter.
- Endpoint: one specific address in an API, such as
/guilds/:guidlId/channels. - HTTP method: the verb on a request saying what kind of action it is, for example
GETto read orPATCHto partially update. - Identifier (ID): a unique string naming one object, such as a message, channel or guild.
- Guild: Discord's internal name for a server that contains channels.
- Channel: a place inside a guild, DM or thread where messages are posted.
- DM: direct message, a private conversation rather than a server channel.
- Thread: a side conversation attached to a message.
- Permission: a rule saying what a user may do in a channel.
VIEW_CHANNEL: the permission controlling whether a user can see a channel at all.READ_MESSAGE_HISTORY: the permission controlling whether a user can read messages already posted in a channel.- Broken access control: a flaw where the system performs an action without properly checking whether the caller is allowed to do it.
- Authorisation check: the step where a system verifies the caller's permissions before acting.
- Explicit Media scanning: Discord's content moderation tooling that accepts message and channel identifiers and returns the matching message objects so attached media can be scanned.
- Message object: the structured record of a message, including its text, sender, embeds and attachments.
- Embed: a rich preview card attached to a message, for example an expanded link with a title and image.
- Media attachment: a file such as an image or video uploaded with a message.
- Gateway: Discord's always-open live connection over which the server pushes events to a client.
- Event: a small message pushed over the gateway saying something happened.
MESSAGE_UPDATE: a gateway event telling the client that a message changed, carrying the message data.- Polling: repeatedly asking the same endpoint on a schedule to see what changed.
last_message_id: a value in a channel listing giving the ID of the most recent message in that channel, updated as new messages are sent.- JSON: a plain text format for structured data, using braces, brackets and quoted field names.
PATCH: an HTTP method meaning partially update a resource.- Websocket: a connection that stays open so the server can push data to the client, the mechanism behind the gateway.
- Recon: the exploratory phase of testing where you map out what endpoints exist and what they return.
- Severity: the rating of how serious a vulnerability is.
- Bounty: a payment made to a researcher for reporting a valid vulnerability.