SolidOS / chat-pane

Solid-compatible chat discussion applet for solid-panes framework
MIT License
10 stars 4 forks source link

chat can impersonate any webId #90

Open bourgeoa opened 1 year ago

bourgeoa commented 1 year ago

This is a real problem. See the discussion in https://gitter.im/solid/solidos?at=63c8360a3031eb336184db17

Some ideas appeared in the discussion :

bourgeoa commented 1 year ago

Some details on the registering of allowed users :

Registering can be an chat extension to the address book aka contact-pane

At registering time a chat user folder can be created for each user with :

With this :

bourgeoa commented 1 year ago

message id will be stored in the chat user folder

We may have only a private key stored in a chat user document This private key can encode the message relative url or the message created date and give a unique security key to store with the message. To improve security message content could be added.

The pod chat owner should be able to rebuild a security key whenever a replacement private key is created That is an audit issue

timbl commented 1 year ago

Another way of doing this is to use the server-side shape validation. To specify a shape which insists not only that a given shape s senr, but also that the USER and the DATETIME are used as fields in the shape.

NoelDeMartin commented 1 year ago

Adding to what @bourgeoa said, maybe we could define a more generic solution for encrypting data in Solid, not just for chats.

For example, we could have triples such as this in the profile:

<#me>
    solid:privateKey <./key.pem> ;
    solid:publicKey <./key.pub> .

Where ./key.pub is public (read-only, of course), but ./key.pem is private and only the POD owner can read it.

Using these keys, we could add "proofs" to other triples/resources. For example, in a chat:

:Msg123456
    dct:created "2023-02-05T16:25:49Z"^^xsd:dateTime;
    sioc:content "this is a message";
    foaf:maker c1:me;
    solid:proof "...".

Such that the value of the solid:proof is an encrypted message of the other triples (normalized, etc). In that way, only the actual user (foaf:maker in this case) can write the proofs, but anyone can check that it's been written by them.

Also, something nice about this is that it can be a client-client standard, so server implementations don't have to change for this to be supported.

bourgeoa commented 1 year ago

@NoelDeMartin thanks. Question : why not use private/public index to store the keys the triples ?

The proof functions could be in solid-logic.

NoelDeMartin commented 1 year ago

@bourgeoa I guess they could be in the type indexes, but that requires using two specs (the type index spec, and the new "security" spec). So I think it's easier just to have it directly on the profile (or extended profile). But sure, I don't see any problem with having them elsewhere if there is any good reason.

About where to have to functions to generate proofs, yes we could have them in solid-logic but it's also important that the spec indicates how the proofs are generated, so that anyone can implement their own algorithm.

bourgeoa commented 1 year ago

@NoelDeMartin Does the security spec covers the client-client ? I thought it was covering client-server.

how the proofs are generated

Are you speaking of the content uses to create the proof. For the chat case which should be Append only the use of the message absolute URI as proof should be enough. Well relative to chat URI might be enough and retain possibility to move the chat to a new pod location.

I have discovered the nostr-tools. n04 https://github.com/nbd-wtf/nostr-tools#encrypting-and-decrypting-direct-messages could cover our needs.

NoelDeMartin commented 1 year ago

Does the security spec covers the client-client ? I thought it was covering client-server.

Well, my proposal is to make it client-client because that way we don't have to wait for servers to implement anything. But sure, it'd be a lot better to make it in the server.

Are you speaking of the content uses to create the proof. For the chat case which should be Append only the use of the message absolute URI as proof should be enough. Well relative to chat URI might be enough and retain possibility to move the chat to a new pod location.

Yeah I suppose if the chat is append-only, the URI would be enough but I don't think we should rely on this. Also because append-only means users can't delete messages, which is an issue. On the flip side, if it's not append-only it means anyone can delete other people's messages :(. But I can't think of a way to work around that without modifying the server spec.

NoelDeMartin commented 1 year ago

@timbl Suggested that a good compromise would be to keep it append-only for most people, but moderators would be able to delete messages.

Building on top of that idea, we could allow people to edit or delete messages, but it would initially be a "soft edit" or "soft delete" (meaning that the document would contain the history of messages, but the UI wouldn't show it). Then, moderators could "approve" those actions and make them effective by really editing/deleting the comments and removing the soft operations.

timbl commented 1 year ago

Yes, that would be a good compromise to only allow moderators or admis ti delete messages. For everyone else it is an append-only world.

timbl commented 1 year ago

One model is that the chat for the day is a folder like ...solidos/solidos/2023/01/01 which is appendable by group members adn writeable by admins. You send a message by writing a new file for that message like

...solidos/solidos/2023/01/01/123406K8jfygTt.ttl

You can make it with a post or a PATCH. Then in the listing of the folder, we save the creator of the file and expose it in the metadata. This is an existing idea which there should be an issue for somewhere. It needs a server change

bourgeoa commented 1 year ago

Ontologies to use for the credentials verification and proof. Looking in verifiable credentials https://w3c.github.io/vc-data-model/#base-context I found the followings ontologies :

The predicate https://w3id.org/security#proof will be be used for the signature.

To describe the signature process this can be done using the verifiable credentials examples. The key being permanent for each webID there is no need to store it in the message. The process can be described only once in the chat index.ttl. An issue arise when a user/webID decides to change his key pair. A solution could be to register the user. The key would be delivered by the registering process and replace the webId as message Owner.

bourgeoa commented 1 year ago

There are RSA et more recently ECDSA certificate types (letsencrypt is is using ECDSA as from version 2 by default. ECDSA is more efficient quicker and have much shorter keys at the same level of security.

nostr-tools offers wrapper functions to create and use ECDSA certificates. the nostr protocol N19 also offer a identity based on the key

bourgeoa commented 1 year ago

@SharonStrats I came to this general idea :

As an inspiration for this process we can use :

SharonStrats commented 1 year ago

I'm wondering what initiates the key pair generation and our transition plan. Thoughts? @bourgeoa @timbl @NoelDeMartin Also just to confirm so this is client-client?

Ideas

Key Generation

Transition plan

bourgeoa commented 1 year ago

Also just to confirm so this is client-client?

At this stage yes. There is no server side specification

Key Generation

It is an app process and should be fully automatic. Later if it is felt that the private key is at risk we may add a second level of security with a password. But it is not the spirit of Solid. WAC should do the job. At least for a chat

Note: no chats or messages can be created from the point this is deployed without keys.

I think that's correct.

Transition plan

I was thinking to have a date parameter or better to display in red or any other colour messages without a proof. This is different from messages where the proof fails.

Otto-AA commented 1 year ago

use the private key to sign a message with a proof being the encrypted hash of messageId+messageContent+owner

A small remark on this: I'd suggest to sign all message fields. In particular also the timestamp and recipient. There's some more discussion here on what could go wrong, feel free to poke me for questions on this: https://forum.solidproject.org/t/update-pod-chat-messenger-2-0-solid-pod-messaging-app/6141/13

bourgeoa commented 1 year ago

A small remark on this: I'd suggest to sign all message fields. In particular also the timestamp and recipient

Agreed I forgot the timestamp. When I wrote messageID I was thinking of the messageUri, that will include what you called the recipient.