LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.13k stars 867 forks source link

Add private messaging #244

Closed Thermovale closed 4 years ago

dessalines commented 5 years ago

Ya this would be a good thing to add at some point. It also needs a block user list too.

poperigby commented 5 years ago

Would something like this support encryption?

Leopere commented 4 years ago

@PopeRigby that would be really cool but might be superfluous to a degree.
Also since encryption seems to be severely under threat of becoming illegal (as absolutely absurd as that sounds) it might be a little bit extra. However if it were to be done.

What could be done is Lemmy would generate a Public ed25519 key pair for each user the public key would be stored internally in Lemmy and never exposed to the end user. You would then store that private key within a PBKDF2 container encrypted with the users password. Then sent to the Lemmy database.

Once the user logs in the PBKDF2 container is then sent from the Lemmy server to the users browser for decryption via some JavaScript, Rust or WebAssembly PBKDF2 library. Where then they will use the Private key for decrypting messages sent to their public key.

Theres a lot to this kind of system but that would vaguely be a really brutal description of how it would function.

Nutomic commented 4 years ago

@Leopere If the private key is stored unencrypted on the server, that means the server admin can decrypt any message. So its not end-to-end encryption. But also, e2e could be added later, there is no need to have it in the inital version (and not even Mastodon or Pleroma support encryption).

Leopere commented 4 years ago

I feel like you didn't read my reply.

Leopere commented 4 years ago

Either that or my reply was a big ball of spaghetti. Let me clarify.

Nutomic commented 4 years ago

Oh sorry, I missed the part "encrypted with the users password". Not sure if thats really secure, because an evil admin could always capture the password during login. Anyway, there is no need to add this kind of feature for the initial implementation.

Leopere commented 4 years ago

Technologies that can be used for E2E direct messages.

GPG with an ECC-384 bit key for Post Quantum resistance encrypted once with the users password. [Used for encrypting the messages] PBKDF2 for storing the GPG Private key previously generated with the users Password. If you don't like GPG you can resort to simply encrypting messages with ED25519 and its asymmetric key cryptography.

This guide shows how to use PBKDF2 so read this.

https://medium.com/@rhamedy/encryption-decryption-of-data-based-on-users-password-using-pbkdf2-aes-algorithms-592f8c1bb79a

Then learn how ProtonMail works and do basically that.

Leopere commented 4 years ago

@Nutomic thats the issue you take on the second you turn your computer on. Gotta trust somebody somewhere. Not saying it's the best option but when federation comes in you don't trust the sysadmin host your own instance and then use that to create and manage your own users.

dessalines commented 4 years ago

I'm thinking about building this, and now I'm pretty torn about doing it, since anything I make isn't gonna be as good, or as secure, as matrix. Mastodon itself has to have a public disclaimer about its private toots/messages not being secure.

Adding matrix would be easy enough, all we'd need to do is add a user field for matrix_id, and have a helper link for people to create an account who don't have one already. Then the private message button, could just be a url matrix link to their user id, which would open up in their preferred messenger. Then people could make group chats and all that.

poperigby commented 4 years ago

Sounds like a great idea. Use Matrix.

Leopere commented 4 years ago

Matrix is an absolute swine to self-host its beautiful tech but it's just a swine.

Nutomic commented 4 years ago

Private message support in Lemmy is necessary if users should be able to exchange private messages with other activitypub implementations like mastodon or pleroma. Besides, not everyone wants to make their matrix account publicly visible. And what about those who forget to link their matrix account?

I don't think the lack of encryption should be a reason to ignore this feature completely. Not all private messages contain critical information, and people might just post the same messages publicly, which is definitely worse. That said, we should definitely put a warning that messages don't have end to end encryption.

poperigby commented 4 years ago

If it doesn't use Matrix by default, I think there should at least be the option to use your Matrix account.

Leopere commented 4 years ago

I think it's an excellent idea to use Matrix as it's a decent technology for a chat platform. Still, the fact that it seems to be a bit of a nightmare to self-host a matrix server makes me think that it as a hard dependency feels a bit silly when ultimately, this would be a way to ditch reliance on others.

I would agree with perhaps using something with the Signal Protocol as it's thoroughly thought through and takes the moderation out of the hands of the operator and implies that the block button should be sufficient for self-moderation again.

poperigby commented 4 years ago

I don't think we should be using Signal. It's completely centralized which goes against Lemmy's decentralization.

Leopere commented 4 years ago

You've completely jumped to a conclusion about the difference between the Signal Protocol and the Signal App and Network itself.

Also to clarify, Signal is no more centralized than any other messaging platform effectively has to be. All mobile platforms Google's Android and Apple's iOS both contain proprietary push systems. You can't write an efficient app without using Firebase Cloud Messaging (FCM) and Apple Push Notification Service.

poperigby commented 4 years ago

You've completely jumped to a conclusion about the difference between the Signal Protocol and the Signal App and Network itself.

I see. I still don't think we should be using a protocol who's maker is so against decentralization.

Also to clarify, Signal is no more centralized than any other messaging platform effectively has to be. All mobile platforms Google's Android and Apple's iOS both contain proprietary push systems. You can't write an efficient app without using Firebase Cloud Messaging (FCM) and Apple Push Notification Service.

Every app on F-Droid doesn't use FCM. Riot is one that I can think of.

Leopere commented 4 years ago

Primarily, in this case, you would use the Lemmy server as the "centralized" server rather than a server operated by OpenWhisperSystems. Which effectively only serves as a signaling relay. It mainly just lets your device know that there is an encrypted message in transit waiting for the device.

The trick is that the Signal Protocol is audited and proven secure to the best of today's standards it would be silly to reinvent something, and in this case, you would be entirely self-reliant.

Every app on F-Droid doesn't use FCM. Riot is one that I can think of. Yes, that may be true; however, if you understand how the power saving modes engage on apps that do not use APNS and FCM, you effectively have to give up the benefit of these battery optimizations. It doesn't make sense that you should not trust the cryptography as the point of the cryptography itself is that it's been peer-reviewed and security audited to be secure within our lifetimes. Cryptographic security doesn't always hold forever, but if you can't trust that the security will protect what you're saying for as long as you need it to, you should not be using the internet to say it. Fundamentally it is impossible to have an entirely secure system on the internet.

I see. I still don't think we should be using a protocol who's maker is so against decentralization.

If he's against decentralization why would he publish his code for free for you and me to use? It's just a classic example of the BDFL governance model. He understands that he is not interested in any metadata and goes to great lengths to express it in his code and design specifications.

If you don't wish to rely on him that's fine; go fork your own! That's the beauty of open-source software. There is no fundamentally good argument to stay with a dictator whose ideals you don't agree. Which in this case, is a perfect example of forking you take what is proven secure safe and as correct as possible, and then you iterate on it. The beauty here is not that it's centralized but that the protocol is already proven.

If you're still concerned about the Signal protocol, it sounds like you may have bought into the FUD over the whole thing. I highly recommend that you have a look at an unbiased deep dive into the technology. It's so well designed that mega tech corps have been integrating it into many other apps such as Skype, Facebook Messenger, WhatsApp, and a few others that aren't coming to mind.

Ultimately the Signal Protocol may be a wrong suggestion, but if the goal is to have private, secure messages this is one of the best protocols.

Simply because you disagree with one facet of a person doesn't invalidate the positive impacts of the products, you should not throw out the baby with the bathwater; especially if you haven't made the time to look into why you're throwing the baby out.

Leopere commented 4 years ago

@PopeRigby, this could be some good reading here for you to look into if you're still distrusting Signal https://www.pindrop.com/blog/audit-of-signal-protocol-finds-it-secure-and-trustworthy/ the acknowledgments made by the protocol is that this isn't a direct connection between two users. You need to recognize the fact that you will never be able to trust the man in the middle of which there are many. Just run a traceroute to any resource online; any hop along the way can be captured and analyzed along the way.

If you assume this is a fact your only remaining option is in the threat modeling and clean OpSec and realizing that you cannot trust anyone, including your device manufacturers and the operating systems on top of them, you only have marginal security at best. The argument for anti-centralization typically remains that anyone with a centralized means for control over what is said between two parties is to be avoided. The Signal Protocol doesn't even know who is talking to whom. Would this not be the perfect solution?

Why not take the control over who can speak to whom on the platform completely away from the operation staff of the Lemmy instance and let it lay in the hands of the end users themselves?

poperigby commented 4 years ago

I think you're misunderstanding me. I think Signal is cool and I trust them, I just think because of Signal's lack of federation capabilities, it's not well suited for a federated social media.

Leopere commented 4 years ago

Ah, that's fair, and it didn't seem to be part of your replies I think that is a definite problem. I wonder how best to integrate Matrix. Would it be reasonable to use it as an OAuth provider kind of thing? I wouldn't want to have to create two users for every user to have chat and posting abilities.

dessalines commented 4 years ago

What I was thinking, was not to add matrix to this project. It could be done, because there are matrix docker-compose projects, but they require a lot of configuration, and would make setup not fun... also synapse is kind of a resource hog.

What I was thinking, was in your user configuration, to add an optional field called matrix id, that people can set to @their_matrix_name:server.

Then, anyone with that set, I can enable a private message button, that opens up a https://matrix.to/ link.

So people wouldn't have to create new matrix users just for lemmy, they could use what they already have.

dessalines commented 4 years ago

@Nutomic

Private message support in Lemmy is necessary if users should be able to exchange private messages with other activitypub implementations like mastodon or pleroma.

That is a good point...

Besides, not everyone wants to make their matrix account publicly visible. And what about those who forget to link their matrix account?

There's probably a user-friendly way to do this. On your user-page, we could have a helper link to the riot create account page, with a warning that you won't be able to receive pms unless you provide this field.

I think that you're probably right that this will be necessary.

poperigby commented 4 years ago

How about we have two options. You can have an insecure option which just uses ActivityPub, and then a second secure option where it replaces the PM back-end with Matrix, if you're communicating with someone else using Matrix. If you try to message someone who doesn't have secure messaging setup, it warns you and falls back to ActivityPub if the user accepts the risks.

Leopere commented 4 years ago

The other potential would be maybe using the OTR protocol which is potentially simpler.

On Tue, Dec 24, 2019 at 3:57 PM PopeRigby notifications@github.com wrote:

So, maybe have two options. You can have an "insecure" option which just uses AP, and then a second "secure" option where it replaces the PM backend with Matrix, if you're communicating with someone else using Matrix. If you try to message someone who doesn't have "secure" messaging setup, it warns you and falls back to AP.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dessalines/lemmy/issues/244?email_source=notifications&email_token=AAIE2VUPR5MC4J4UYIYTWNLQ2JZSVA5CNFSM4IRQFLTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTTSFA#issuecomment-568801556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIE2VV7KTF32ROCUKT7QJ3Q2JZSVANCNFSM4IRQFLTA .

dessalines commented 4 years ago

@PopeRigby I like this idea a lot. Basically just a secure private message and an insecure private message button, the secure one grayed out unless they have a matrix id field added.

Leopere commented 4 years ago

I stress out about unnecessary coupling with external things but as long as it's optional and functions relatively seamlessly then it sounds like a great idea.

ptman commented 4 years ago

@Leopere when did you last look at hosting your own matrix home server? It has improved a lot lately.

Leopere commented 4 years ago

Some point in the last few months I managed to spin one up but it wasn't pretty and didn't federate nor did it seem to have most of the additional features. It seems strange to ship something that's somewhat non-functional by default.

ptman commented 4 years ago

I wonder what steps you took, but no matter. It can be quite simple: https://matrix.org/docs/guides/free-small-matrix-server/ .

Leopere commented 4 years ago
version: "3"
services:
  postgres:
    image: postgres:9.6.4
    restart: always
    volumes:
     - ./data/pgdata:/var/lib/postgresql/data

    # These will be used in homeserver.yaml later on
    environment:
     - POSTGRES_PASSWORD=synapse
     - POSTGRES_USER=synapse

    networks:
      - traefik

    labels:
      - "traefik.expose=false"

  synapse:
    image: silviof/docker-matrix
    networks:
      - traefik
    restart: always

    # Exposing 8008 (no TLS) on localhost means we can reverse proxy with nginx
    # 8448 is for federation and should be exposed on host
    # 3478 is for TURN (voip calls)
    expose:
     - 8008
    ports:
     - "8448:8448"
     - "3478:3478"
    volumes:
     - ./data/synapse:/data

    labels:
      - "traefik.port=8008"
      - "traefik.frontend.rule=Host:chat.redacted.com"
      - "traefik.backend=synapse"
      - "traefik.docker.network=traefik"
      - "traefik.expose=true"

# Our docker network!
networks:
  traefik:
    external: true
Leopere commented 4 years ago

@ptman the above reply is what I compiled docker-compose wise as it seems that there was something I tried with Matrix's default containers that didn't work as to follow some kind of standard somewhere that didn't work out right.

dessalines commented 4 years ago

@ptman 's guide uses this project to configure and set up matrix: https://github.com/spantaleev/matrix-docker-ansible-deploy/

I suggest reading through those ansible deploy files to see how incredibly complicated the setup has gotten (esp with all the optional addons).

I'm not going to bundle matrix into this project, because of

What I think is the best of both worlds, and that I will work on at some point, is to add:

Leopere commented 4 years ago

I think that if we're going to support Matrix we should have a way to deploy it with recommended settings from this project OR not bother to add it.

ptman commented 4 years ago

I haven't yet seen a simple federated system. It's true that matrix-docker-ansible-deploy is complex, but it supports a very wide range of options. I'm sure someone could make a simpler setup. I have a relatively simple setup on nixos with docker.

Leopere commented 4 years ago

It should work by default then you can break it or screw it up all you like afterward.

On Wed, Jan 8, 2020 at 3:50 PM Paul Tötterman notifications@github.com wrote:

I haven't yet seen a simple federated system. It's true that matrix-docker-ansible-deploy is complex, but it supports a very wide range of options. I'm sure someone could make a simpler setup. I have a relatively simple setup on nixos with docker.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dessalines/lemmy/issues/244?email_source=notifications&email_token=AAIE2VRFCPDPPM4CNH45G3LQ4Y37XA5CNFSM4IRQFLTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIN5WAI#issuecomment-572250881, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIE2VUBDVILHZILICH24BDQ4Y37XANCNFSM4IRQFLTA .

dessalines commented 4 years ago

@Nutomic mastodon / apub supports group pms right?

Nutomic commented 4 years ago

Mastodon doesn't natively support groups, you can address a private message to multiple people though. Not really sure about activitypub but its most likely possible.

dessalines commented 4 years ago

Do the replies to a group private message go to all others messaged? Like a chatroom. Or is it just several individual one on one pms.

Nutomic commented 4 years ago

Its the same message visible to multiple people, everyone is tagged receives it and sees all the other who are tagged.

trymeouteh commented 3 years ago

Would like to see later on a simple E2EE private messanger built into Lemmy.