Discourse Encrypt (deprecato)

Original Plugin Description
:discourse2: Summary Discourse Encrypt enables private, encrypted messaging between end-users. All sensitive information is stored securely on the server and is encrypted and decrypted only on the client-side.
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-encrypt
:open_book: Install Guide How to install plugins in Discourse

Three easy steps to use this plugin

  1. Enable encryption and activate current device.

  1. Send an encrypted message. The recipient must also have enabled encryption.

Optionally, you can determine the time after which the whole message or specific post will be permanently destroyed

  1. Read secret messages. Encryption must be activated first to read them.

Note: In this example, the user was prompted for paper key again because encryption was deactivated (by logging out or explicitly deactivating it from preferences screen).

Technical information

This plugin gives users the possibility to communicate securely through Discourse, by using an end-to-end encryption scheme. Most of plugin’s logic is implemented on the client-side and the server-side handles only public or encrypted information. It does not encrypt any post metadata, such as names of participants in the conversation, posted time, likes, small actions, etc; uploads are encrypted, but their presence is not because the system must associate uploads with posts to prevent deleting them.

The whole code is open-source and security enthusiasts are welcome to review it. For any further information, do not hesitate to contact me or the team. :slight_smile:

read more...

Summary

The goal of this plugin is to offer integrity and confidentiality of the encrypted contents, and to protect it against information leaks and unauthorized users. The following sections describe the usual operation mode, used algorithms and threat models.

To use this system, users enroll once by generating a “user identity” consisting of two 4096-bits RSA keys, one for encryption and another for signing. Users can export their “identity” for safe keeping or store it on the server, encrypted after generating a paper key. These two methods serve as backups or are used to enroll new devices.

Paper keys (inspired by RFC 1751 and BIP-39) are human-readable keys that are used to securely store the “user identity” on the server. A paper key consists of 12 random words, picked from a list of 2048 words, offering 121-bits of entropy (the first word is used as a label). To encrypt the “user identity” with a paper key, the system will first derive the encryption key using PBKDF2 to stretch the paper key into a 256-bit AES-GCM key.

Creating an encrypted post

To create a new post, the user (their browser) will:

  1. sign the current post content using their private signing key;

  2. generate a new “topic key” (a AES-256-GCM key) - which is going to be used to encrypt the post, some post metadata and the title of the new topic (if available);

  3. fetch the public keys of all participants and encrypt the “topic key” for each of them;

  4. send to the server the encrypted post (Base64 encoded) and the encrypted topic keys (also Base64 encoded) of each participant.

The pseudocode for the encryption operation would be something like:

signature = rsa_pss_sign(current_user.identity.sign_key.private, post.raw) # 1
topic_key = topic.key || generate_aes_256_gcm_key() # 2
encrypted_title = aes_256_gcm_encrypt(topic.title, topic_key) if topic.blank?
encrypted_post = aes_256_gcm_encrypt(signature + post.raw, topic_key)
encrypted_topic_keys = recipients.map { |r| rsa_oaep_encrypt(topic_key, r.identity.encryption_key.public) } # 3
$.put("/posts/create", { title: encrypted_title, raw: encrypted_post, keys: encrypted_topic_keys }) # 4

Reading an encrypted post

To read a post, the user (their browser) will:

  1. fetch the encrypted post payload (post plaintext and signature) and encrypted topic key;

  2. use their private encryption key to decrypt the encrypted topic key;

  3. use the decrypted topic key to decrypt the encrypted post payload;

  4. fetch the public signing key of the poster and verify the post signature.

Algorithm Suite

This plugin makes extensive use of the cryptographic primitives implemented in Web Crypto API, which are available in any of the modern browsers Discourse supports (except Internet Explorer).

  • getRandomValues PRNG: It generates paper keys and 96-bits random IVs.

  • PBKDF2: It stretches the 132-bit paper keys to 256-bit keys, used for encrypting “user identities”.

  • AES-256-GCM: Used to encrypt each post’s content. It also offers authentication by producing an authentication tag of 128-bits, but this is a less important aspect because posts are verified using a signature generated by the poster (see step 1 above).

  • RSA-OAEP: Used to encrypt “topic keys” and “user identites” for safe-keeping on the server. All RSA-OAEP keys are 4096-bits long.

  • RSA-PSS: Used to sign each post’s content for verifying authenticity. All RSA-PSS keys are 4096-bits long.

Primitives

The system uses a set of primitives built on top of those provided by the browser via Web Cryptography API.

  • encrypt and decrypt: Used to encrypt and decrypt post contents. encrypt takes a JSON, an AES-256-GCM key and a RSA-PSS public key and outputs a single Base64 encoded string; decrypt takes a Base64 encoded string and an AES-256-GCM key and outputs the initial JSON object;

  • verify: Used to verify post contents after decryption;

  • exportKey and importKey: Used to export and import “topic keys”;

  • exportIdentity and importIdentity: Used to export and import “user identities”.

Types of keys:

  • topic keys (AES-256-GCM)

  • RSA key-pair (public and private keys) (RSA-OAEP and RSA-PSS, 4096-bits)

    • used to encrypt all topic keys a user has access to
    • are generated per user on the client-side by the original poster using WebCrypto’s API generateKey primitive and shared amongst all of user’s devices
    • server-side: public identity is stored as exported by the client, but the private identity will always be encrypted with the passphrase key
    • client-side: public and private keys are stored as CryptoKey in IndexedDb; if not possible, it will use window.localStorage (in Safari)
  • passphrase keys (derived using PKBDF2 with 128,000 iterations)

    • used to encrypt “user identities” for safe storage on the server
    • derived from a paper key (or user’s passphrase for legacy purposes)

Threat models

Compromised Discourse Instance

An attacker which can inject code could in theory access encrypted information by serving malicious code, which decrypts the encrypted content and sends the plaintext posts to another server. To make this possible, it is enough to have access to an administrator account and create a theme component with the malicious code.

Default protection mechanisms such as CSP can detect and mitigate Cross Site Scripting (XSS) attacks that could also represent a way of injecting malicious code.

Man-in-the-Middle Attack

In Man-in-the-Middle attacks, the attacker intercepts the communication between the user and server, giving them the ability to read or alter it. Because the plugin encrypts everything before sending, an attacker cannot decrypt anything by simply eavesdropping. Similarly, because information is authenticated the attacker cannot alter it.

However, the attacker could serve malicious code back to the user and follow a similar attack to the one presented in the previous section. This is partially mitigated by HTTPS, which is considerably reducing the attack probability.

Notes

The plugin already has a little history and that can be seen while browsing the source code and noticing the two implementations of the protocol v0 (initial, alpha-beta release) and v1. Protocol v0 is no longer used to encrypt new posts, but kept to continue decrypting old ones. New protocol includes authenticity of the ciphertexts and all posts are signed with the private key of the poster.

Other Resources

Last edited by @david 2024-12-03T15:46:08Z

Check documentPerform check on document:
98 Mi Piace

11 messaggi sono stati divisi in un nuovo argomento: Nascondi completamente i messaggi parziali per il gioco di ruolo

Come posso abilitare l’invio di messaggi crittografati ai gruppi? Tutti gli utenti del gruppo e il mittente del messaggio hanno la crittografia abilitata, ma ricevo ancora il messaggio di errore:

“Non si dispone dell’autorizzazione per inviare messaggi crittografati ai gruppi.”

3 Mi Piace

Non credo sia attualmente possibile inviare messaggi privati crittografati ai gruppi.

2 Mi Piace

Ciò significa che la casella di posta del gruppo si romperà? E/o invitare un gruppo a un pm non funzionerà?

Questo, non era possibile in primo luogo.

È necessario inviare una segnalazione di bug per questo malfunzionamento?

Tutto sembra attivo, tranne il normale ritardo nell’apertura, ma i messaggi privati non sono crittografati.

1 Mi Piace

Non c’è bisogno di pubblicare su più canali, ma se desideri trasformarlo in un Bug report anziché in una richiesta di Support puoi seguire queste linee guida e poi ricategorizzarlo - Writing an effective bug report

Anche se vale la pena notare che sia i bug report che le richieste di supporto possono richiedere tempo per ottenere trazione, specialmente durante il fine settimana.

5 Mi Piace

:mega: Purtroppo, a causa del tasso di adozione relativamente basso e dell’alto costo di manutenzione, il supporto per discourse-encrypt verrà interrotto dopo il prossimo rilascio stabile di core nel Q1 2025.

Il post originale di questo argomento è stato aggiornato con maggiori informazioni e introdurremo un avviso automatico per gli amministratori dei siti interessati.

14 Mi Piace

Speranza che venga sviluppato in futuro.
Questo è molto importante/utile nei settori dei dati/blockchain/sicurezza.

6 Mi Piace

10 messaggi sono stati divisi in un nuovo argomento: Non mostrare argomenti e messaggi privati agli amministratori a meno che non siano partecipanti

Continuando la discussione da Discourse Encrypt (deprecato):

È giunto il momento e l’ultimo aggiornamento di Discourse sembra essere incompatibile con Discourse Encrypt.

I nostri sintomi sono che nessuno è in grado di rispondere a un post; il sistema inizia a caricare la vista di risposta ma non riesce mai a caricare l’editor effettivo.

Disattivare Discourse Encrypt elimina il problema, riattivarlo riporta il problema.

Poiché questo plugin è deprecato, non lo segnalo come bug, lo segnalo solo in modo che altri possano aspettarsi questo comportamento.

Inoltre, se qualcuno conosce risorse che potremmo indicare a persone che desiderano scaricare messaggi crittografati e decodificarli offline, saremmo grati.

4 Mi Piace