Fossil Forum

Private messages, private keys, and beyond
Login

Private messages, private keys, and beyond

Private messages, private keys, and beyond

(1.1) By andygoth on 2018-10-19 15:51:01 edited from 1.0 [source]

I seem to remember there being a request for private messages in the forum. If we really want this feature (and I really doubt we do), the only way I can think to do it within the architecture we have is to encrypt the private message using the recipient's public key. The recipient can then decrypt using the corresponding private key.

For this to work, Fossil would need to be extended to store each participating user's public key. As a convenience, Fossil could store private keys as well, but only if those private keys are themselves encrypted with a passphrase known only to the user.

Aside from enabling private messages, this feature could be used to sign manifests and other artifacts. Fossil already has PGP support, though I'm not sure it still works because I don't see anyone using it. (Update: drh uses it for TH3)

Perhaps Fossil could implement its own signature system so as to avoid depending on PGP. We've already got good SHA* code, we wouldn't have to worry about PKI or trust or anything beyond the one keyring, and we wouldn't have to be PGP-compatible. Though we'd need to add AES code. We probably would also want Fossil to be capable of generating keys in the first place, which means picking huge prime numbers and so forth. (Last year I successfully implemented all this same stuff in Tcl using the Tcllib pki module, so I know it can be done.)

Fossil could reject artifacts lacking a signature, having an invalid signature, or signed by someone whose public key is (no longer) in the keyring.

For extra fanciness, Fossil could also reject artifacts that accomplish a change the signing user doesn't have permission to make. For example, maybe a project might want only certain people to be able to modify certain directories, or commit to certain branches, or create/modify symbolic tags matching (or not matching) certain regular expressions, or edit certain wiki pages, or post to certain sub-forums (assuming we'll get that feature someday), or change tickets from/to certain states, etc.

This is a big can of worms, for many reasons. It's a massive increase in the complexity of the capability system. I imagine rules might be written in TH1.

Should a user try to change a file that user isn't allowed to change, or do anything else that's not permitted, the Fossil client would have to reject the commit (or artifact) without ever trying to push it to the server. Otherwise forks will be created which cannot be sync'ed upstream, just like when a user doesn't have blanket commit access and tries to commit anyway. Yet, if the client and server disagree on user capabilities, this problem will occur anyway. Maybe this could be solved by sync'ing the user capabilities and associated rules during the pull that occurs just before actually performing the commit. That might end up being a lot of data to repeatedly fling around, becoming a problem unto itself.

The ability to create forum posts, wiki pages, etc. can currently be limited by capabilities. In addition to the web interface being hidden when denied, I imagine the current Fossil server rejects artifacts matching those schemas (formats) corresponding to capabilities denied to the user. Otherwise anyone could push forum posts, etc. they're not allowed to make, just by granting themselves the necessary capabilities in their local clone, then sync'ing upstream. If my guess is correct (and I'm not curious enough to try it myself right now), it's not possible for a user who is not allowed to create forum posts to push upstream forum posts made by another person who legitimately has that capability. Furthermore, someone who does have that capability can push upstream forum posts made by someone who doesn't. Having the individual artifacts be signed by their originator and accepted/rejected according to capabilities associated with the signature key (rather than the person doing the push) could solve these issues.

One more thought on private messages. Only mirrors/backups would be interested in downloading encrypted artifacts they will never be able to read. Everyone else would probably prefer to not receive encrypted artifacts for which they don't have the key. However, this determination is a bit tricky. Just because an artifact resembles an encrypted private message doesn't mean it's not a checked-in file. Thus some graph analysis would be needed to check if the artifact is unreferenced by any manifest (or ticket or wiki or forum attachment, etc.), in addition to checking if its schema corresponds to private message (or more generically, encrypted artifact), and cannot be decrypted by the user's private key (or doesn't contain the user's name, public key, or fingerprint, depending on how we design the format). One possible approach would be to have the private message and its "envelope" be separate artifacts. The private message would be a blob that only gets sync'ed if referenced by something other than what's recognized as an unopenable envelope. There's a lot involved here.

Okay, another thought on private messages. How would they ever be deleted? If only the recipient can read them, the recipient might decide they are no longer of use and ask that they be deleted. How does that delete operation propagate through the network? I'd hate to have to invoke the shun logic for this. Does a non-nuclear option exist?

And a third thought. I know it's possible to encrypt a message such that it can be decrypted by multiple private keys. (I'm pretty sure the algorithm is to use AES, etc. symmetric encryption for the message then asymmetrically encrypt the randomly-chosen AES key using each private key.) I'm pretty sure we'll want private messages to be readable not only by the recipient but also the sender. So if we already have to implement two people being able to read a message, why not more? This gets really fancy really quick.

There's a lot of bloat and complexity here, and my ideas are all half-baked or worse. But they are ideas I wish to write down and share.

I think the bottom line is we don't want this stuff, yet it seems exciting enough to me that maybe it can nevertheless be kept as a back-of-the-mind goal to gradually work toward in the years to come. In particular, prior to widespread adoption of Fossil, my organization would need much tighter control of permissions, such as the examples given above.

(2.2) By andygoth on 2018-10-23 15:27:16 edited from 2.1 in reply to 1.1 [link] [source]

Here's another thought for private messages, also addressing a number of other wishlist ideas I've had for forums.

Instead of putting private messages in the blockchain interspersed with check-ins and forum posts, Fossil could add a per-user storage area to collect private messages, preferences, read/unread forum history, forum thread subscription ("follow") settings, encrypted private keys, persistent stash, private branches, date format, timezone, custom skin, things we currently use cookies for, and so forth.

As for the artifacts themselves, one possibility is to segregate them from the normal blob table, though this is potentially wasteful of storage. A more advanced solution would be to put them in with the rest of the blobs but keep track of whether they are referenced by the default blockchain and/or by particular user storage areas. On sync, only the blockchain and user-specific artifacts would be pulled.

This should also help address the shun problem. I don't want to have to issue shun records every time a user deletes a private message. Instead, once the private message artifact is no longer referenced by any storage pool (not by the enduring blockchain, not by any user storage areas), it gets deleted.

As mentioned in my previous post, this implies a distinction between a regular user sync'ing and a mirror/backup sync'ing.

I feel like this could be made into a more generic system capable of storing configuration and unversioned artifacts.

(3) By anonymous on 2018-11-06 18:26:32 in reply to 1.1 [link] [source]

I don't think Fossil needs a complete PM system.

A simple ToxMe discovery service might be useful though. Here is an example: https://github.com/LittleVulpix/toxme It'd mean only a few more fields in the database and the API calls don't require much complexity either.