Skip to main content

Using Malicious Discord Apps to Access User Data Through OAuth2 Permission Grants

Illustration of Using Malicious Discord Apps to Access User Data Through OAuth2 Permission Grants
Martin Matyja

Introduction

During a recent red team campaign, we discovered an unusual method of tricking users into potentially malicious activity. One of our client’s domains had been forgotten and was still pointing to an IP address owned by a VPS provider. Someone else gained control of that IP by deploying their own VPS instance. As a result, they were able to perform a classic subdomain takeover attack and host their own content on the client’s subdomain.

The typical, predictable tactic is to either host content similar to that of the original domain owners or create phishing pages designed to trick users into revealing credentials or downloading malicious software.

In this case, the HTML included only a simple logo and a button. The button redirected users to a Discord OAuth2 invitation link for one of the Discord Apps, specifically, the hosted application created by our actor. The link looked like this:

Discord OAuth2 link

The link directs to Discord’s OAuth2 authorization endpoint. By including the client_id, it specifies which Discord app is requesting access to the user’s data. The redirect_uri parameter defines where the user will be redirected after completing the authorization process. Another key parameter is scope, which outlines the permissions the user grants to the application by clicking the link.

This article does not cover subdomain takeover attacks; instead, it focuses on the Discord App. We will explore an intriguing method of collecting user data by creating a Discord App for phishing purposes and analyse the types of data such an app can access.

Discord App overview

Discord Apps, also known as Developer Apps, are bots or programs integrated into Discord servers to enhance communities with additional features, tools, and automation. If you use Discord, you’ve likely interacted with one of these apps running on a server you belong to.

These apps use OAuth2 for secure user authentication and permission management, ensuring user credentials remain private. OAuth2 allows users to grant specific access privileges, enabling safe integration of bots and external services while improving security, privacy, and control over connected applications.

Discord App permissions

You can configure a variety of permissions that a Discord App can use on behalf of the user who grants access. Let’s look at some of the permissions that can be granted to the app:

  • identify – allow to obtain various information about the profile, but without the email address.

Example data object for one of the accounts used during the creation of this article:

User profile data

  • email – the same as identify but with email address included
  • connections - allows to return linked third-party accounts
  • guilds - allows to return basic information about all a user’s guilds.

Some permissions require Discord approval and were not tested during the article’s creation. However, they present additional potential methods to gain broader access to a victim’s data. Examples of notable permissions include:

  • dm_channels.read - allows app to see information about the user’s DMs and group DMs
  • applications.builds.upload - allows app to upload/update builds for a user’s applications
  • relationships.read - allows app to know a user’s friends and implicit relationships

Example scenario

Let’s create a simple app that impersonates the brand with little modification - Sékurak. To increase trust, the app includes a logo generated by one of the most popular LLMs:

App logo

The next step is to specify the permissions our Discord app will request from the user.

App permissions

Discord will then generate a URL structured like the example shown at the beginning of the article. When the user enters this URL in their browser, they will be redirected to a Discord page containing a form to authorize the app to access the specified account permissions.

Authorization form

The bottom section of the form also reveals some information about the Discord app:

App information

Let’s be honest, it’s hard to overlook the information about the permissions an app requests. Discord presents this information transparently, helping users clearly understand the permissions they’re granting. It’s a great approach!

Therefore, the burden of phishing persuasion should be shifted to the source of the link granting permissions, i.e., the HTML code, logo and app name.

When the user clicks the “Authorize” button, access is granted, and they are redirected to the previously specified URL with code value:

Authorization code

Let’s review a basic HTTP server with a redirection handler using the Express framework. Below is the endpoint handler:

Express handler

To obtain an access token, we need to send a request to the appropriate endpoint using our code value (typical OAuth2 authorization code flow).

Token request

Obtaining access token to access Discord API latter:

Token response

Response from the request above:

Token response data

Now that we have an access token, we can request data from the Discord API on behalf of the user.

To retrieve the user’s profile data, send a request to the /users/@me endpoint:

Profile request

Example response of the user data:

Profile response

Another example is retrieving information about the Discord guilds (servers) the user belongs to, which can be done as follows:

Guilds request

Example response showing membership in the Midjourney server:

Guilds response

Conclusion

This article shows a simple method to create an application that may attempt to access user data on the platform. Since Discord openly displays user permissions, it’s possible to impersonate any “app identity,” such as a well-known brand. This impersonation can greatly improve the chances of gaining access, especially when combined with social engineering tactics like offering a “free voucher for a certificate” through the Discord app.

To protect your data, follow these guidelines:

  • Always review the permissions the Discord app is requesting.
  • Verify the app’s authenticity and confirm it’s from the creator you trust.
  • If you don’t need the app, avoid using it and don’t grant any permissions.

Other Insights

Illustration of MAC Spoofing Made Easy: Lessons in LAN and Physical Security from a Real Pentest

MAC Spoofing Made Easy: Lessons in LAN and Physical Security from a Real Pentest

Krystian Działowy

During a penetration test for one of our clients, we were tasked with analyzing the risk of unauthorized endpoint access to the internal network, specifically checking whether an untrusted device could connect without prior authorization. We tested exactly that scenario, walking into an open conference room and connecting a laptop using a random MAC address. Although the device received a DHCP lease, access to internal resources was blocked and EDR registered the connection attempt. However, the story didn't end there.

READ article
Illustration of XXE using J4LFOPServer leading to Remote Code Execution

XXE using J4LFOPServer leading to Remote Code Execution

Jakub Żoczek

While testing the LAN infrastructure of one of our clients I discovered that one of the applications is handling XML input which led to finding critical vulnerabilities. By allowing the definition of custom entities within XML input better known as XML External Entity (XXE) the application exposed itself to a range of serious threats, including local file disclosure, external network interactions resulting in NTLMv2 hash leakage, and most notably, Remote Code Execution through the use of XSLT templates.

READ article
Illustration of Wipe and Rise: How Deleting Folder on Windows Enables LPE

Wipe and Rise: How Deleting Folder on Windows Enables LPE

Mateusz Lewczak

Time-of-check-to-time-of-use (TOCTOU) race conditions have plagued Windows software for decades, yet they still surface in modern code. During a recent audit of TestedAPP we uncovered a textbook example: the application's background service first checks whether a cache directory exists and, milliseconds later, deletes it without re-validating the path. Because every non-privileged user can create files and folders inside the application tree, an attacker can win the race, swap the legitimate directory for an NTFS mount point, and redirect the deletion to any location on the system drive.

READ article
A professional cybersecurity consultant ready to assist with your inquiry.

Any questions?

Happy to get a call or email
and help!