YSCodes

Discryptor: End-To-End-Encryption for Discord Private Chat

Read on discryptor.io

Discord private chats are still not end-to-end-encrypted, nor does it look like that will happen any time soon. This may lead to your sensitive private communications potentially getting compromised, not only by Discord itself, but also anyone Discord may share your data with as well as a potential hacker breaching Discord security.

That's why I developed Discryptor, a separate app that allows for E2EE-messaging over Discord using your existing account. I hereby present the Discryptor BETA for Windows in the hopes of evaluating the idea. In the following, I would like to explain the architecture of the system, some of its cryptographic properties as well as how to use it.

Client-Server Architecture

Discryptor has a client and a server component: The Discryptor app and Discryptor server. When you send a message in the app, it is encrypted and sent to the Discryptor server. The server delivers it to the recipient using a messenger bot that lives in the same Discord server as the communicating users. The recipient decrypts the message.

The Discryptor bot (named "DiscryptorMessenger") is a public Discord bot that can be added to any server. Any two users that share a Discord server with DiscryptorMessenger can communicate safely and privately via Discryptor.

The Client-Server architecture may perhaps seem unnecessarily complex, so here's how it came about:

To prevent abuse, the Discord API doesn't allow for automated direct messaging using user accounts. Only bots may be used for that purpose. However, bots can only message users from a mutual Discord server. The Discryptor bot (named "DiscryptorMessenger") is a public Discord bot that can be added to any server. It can be found in the official Discryptor Server here. Any two users that share a Discord server with DiscryptorMessenger can communicate safely and privately via Discryptor.

Prerequisite to using Discryptor

In order to securely chat via Discryptor, both users need to share a common Discord server with the delivery Bot named DiscryptorMessenger. This is a public bot that can be added to any Discord server, thereby enabling all users in the server to use Discryptor. You are welcome to join the official Discord server to get started and try it out.

Key creation and storage

When you create your keys in Discryptor upon first use, an RSA master key pair is created. PBKDF2 is used to derive an AES key from your Discryptor password to encrypt your private RSA key with. The public and encrypted private RSA keys are then sent to the Discryptor server. This facilitates synchronization of your communications across all your devices without breaking E2EE.

Key exchange

Discryptor employs a simple friend system that has two purposes:

When you add a user as a friend, Discryptor creates an AES key, encrypts it using the other user's public RSA key and sends it to the Discryptor server where the friendships are managed.

Once the user accepts the friend request, they decrypt the key, encrypt it with your public key and send it to the server as well. At this point, a friendship has been established and a permanent encryption key securely exchanged.

Authentication with your Discord Account

Since Discryptor runs on top of the Discord API, essentially using only a bot account, there must be a way to authorize and authenticate your Discryptor Client in order to act on behalf of your actual Discord account.

To achieve that, I created a challenge-response scheme, whereby the client requests a challenge (random string) from the Discryptor server and is asked to direct message it to the messenger Bot. This proves both that the user has access to the Discord account they claim to be the owner of, as well as them being part of the Discord server in which the Bot lives.

On successful authentication, the user get a JWT token to authorize all the subsequent calls to the server. I'm aware of the weaknesses of JWT - primarily the inability to revoke them except by storing them, which would make them no more useful than simple bearer tokens - however I believe for starters they should do. That's because a stolen JWT is not enough to fully hijack a user's Discryptor account: Without knowledge of the password used to generate the keys, no messages can be read or sent.

Quick Demo

Discryptor Demo

When you first use Discryptor, you enter your Discord ID and a new password that is used to protect your keys. After doing so, you can immediately log in. On Login, you will be required to authenticate with Discord by sending an auth token to the DiscryptorMessenger bot. Thereupon you will be met with a very familiar looking UI that resembles actual Discord. You will need to add other Discord users inside Discryptor first in order to start chatting. For example, you may add me, YSCodes#7098 to test it out (and perhaps send me your secret feedback, thanks!).

Current state

When I started with prototyping the system, I used WPF to create a Windows client. I thought of it as quick way for me to prototype the thing first as I'm simply very familiar with the technology. During my endeavours, however, I realized how underrated WPF actually is when it comes to creating native Windows apps and made it into a full blown app - Long live native Windows Software!

The backend is written with C# ASP.NET which comes with Kestrel as a webserver. The Discryptor server is hosted at a local hosting provider in Germany.

Discussion

During the course of this project so far, some trade-offs had to be made. The main guiding principle for all decisions was ease of use for the end user without technically breaking E2EE. Some of these aspects are the following:

Going from here

The next two obvious steps for this app to become more viable would be:

I'm open to feedback and would really like to build a small community around the purpose of this project: E2EE for Discord private chat. Perhaps there are better ways to achieve what I'm trying to - In any case I'm looking forward to hearing your thoughts.

Again, you are welcome to join the official Discord server, try out the BETA yourself and leave your feedback which may well shape the future of the project.

Thank you for reading!

For updates and news regarding this or any other of my projects, follow me on Twitter.

#projects