dcposch / scramble

Secure email for everyone
http://dcposch.github.io/scramble/
226 stars 32 forks source link

Unencrypted sent mail should be stored encrypted #43

Closed dcposch closed 10 years ago

dcposch commented 10 years ago

Currently, when a Scramble server receives unencrypted mail, it encrypts it with the recipient's private key before storing it. This has a security advantage. It could also simplifies the code: the client simply sees all mail in encrypted form, regardless of source.

Unfortunately, the client currently has to deal with unencrypted sent mail---if a user sends email to an outside address, it goes into their Sent box w/out encryption. Ideally the server would never store plaintext on disk.

To fix this, I propose queueing outgoing email in a chan and having a fleet of worker goroutines sending them out. This would replace the current mechanism, where the outgoing mail is saved to the DB and the SMTP sender polls the DB. Advantage: it's simple, and we keep the invariant that plaintext is never stored to disk. Disadvantage: if the server crashes, the last few seconds worth of outgoing mail may be dropped. (There are nice way to mitigate this---for example, saving drafts to the user's encrypted blob store---so that they can manually retry in case of a failure.)

Note about the security advantage

This does nothing against a wiretap or other surveillance----if users want protection from that, they need to email other Scramble addresses or provide a PGP public key!---but it does protect against retroactive searches. Nobody, not even the server, can read a users inbox after-the-fact.

jaekwon commented 10 years ago

Done, except the chan part. It is implemented as a synchronous SMTP operation initiated by the user's HTTP request. Plaintext never enters the disk, save memory paging issues.