haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.26k stars 1.54k forks source link

Encrypted libraries leak lots of information #350

Closed ef4 closed 4 months ago

ef4 commented 11 years ago

I spent some time auditing the crypto constructs for Seafile's encrypted repos, because I'd like to help make Seafile more secure and trustworthy. I found some significant problems.

An attacker who obtains a copy of the encrypted library without the key can:

Furthermore, since the same initialization vector is reused for all chunks, the library is vulnerable to watermarking and known-plaintext attacks.

The first problem is straightforward to solve: encrypt all file and directory entries, not just the content chunks.

The second problem (predictable IVs) is not as easy to fix. To maintain seafile's existing deduplication and synchronization capabilities, you want deterministic encryption. But maintaining semantic secrecy with deterministic encryption is probably not possible.

As a practical improvement, you could use an HMAC of each chunk as its IV. This is still deterministic, but it would at least prevent chunks with the same prefix from sharing the same ciphertext prefix.

To achieve strong secrecy, Seafile would need to give up deterministic encryption. This can still provide reasonable reduplication and efficient sync, but it would require clients to maintain their own cached mapping from chunk sha1 sums to their encrypted identities. You may want to look at how the Tarsnap client does something similar.

killing commented 11 years ago

Thanks for your suggestions.

Encrypting file and directory entries has been discussed for some time. It'll be added in the future. But it takes a lot of effort so we don't have time to work on it currently. If file and directory entries are encrypted, we have to decrypt them when browsing the files from the web. That requires a lot of changes.

I don't quite understand why using a single IV for the whole library is vulnerable to known-plaintext attacks. The IV is derived from the password with salt. It's deterministic, but not so predictable. If it's so bad to use this method to produce an IV, it's bad to derive the key from password too. I know it's better to use different IV and key for each file/block. But that would greatly increase complexity.

ef4 commented 11 years ago

It's bad for the same reason that ECB mode is bad: patterns in the data remain visible as patterns in the ciphertext. The only difference is that in this case we're talking about patterns of chunks instead of patterns of cipher blocks. I think it's possible to guess with good probability whether a repo contains certain files, just based on the statistical patterns of blocks with shared common prefixes.

An attacker can often guess that a repo might contain some well-known file. But combined with the plaintext file & directory metadata, I don't even need to guess. For example, if I see a file containing 35684 bytes named "seafile/common/processors/blocktx-common-impl-v2.h" in your encrypted repo, it wouldn't take much guessing for me to know exactly what the plaintext of that file must be. Then I can run the chunking algorithm over it, and I learn what the first 16 bytes of each block always encrypts to (because the IV never changes). I can then search for other blocks that start with those same patterns, and now I know some of the plaintext of your other files, too.

Repeat over and over for every known or guessable plaintext, and an accurate statistical picture of some of your private data can emerge. Or even worse, maybe I can send you some chosen plaintext (like a specially crafted PDF) and get you to stick it in your repo. That opens up even better attacks, because I can choose the chunking, tag my chunks with common shared prefixes of various lengths, and then accurately sample how the rest of each chunk encrypts.

Anyway, I'm just an amateur interested in improving open source security. Maybe try to engage some dedicated crypto discussion groups -- I bet you'll get an earful about potential risks. Then you can decide if those risks matter to your threat model.

Thanks for Seafile, if I didn't think it was useful I wouldn't spend time looking for security bugs. :-)

q000te commented 10 years ago

I second the need to encrypt all file and directory entries within encrypted libraries. Furthermore the use of an HMAC of each chunk as its IV seems like an useful enhancement.

tinco commented 10 years ago

Having the same IV every chunk is the same as having no IV. You are not using the protocol in the way it was designed, so you are vulnerable to the attacks the protocol was designed to defend against. Using the HMAC of each chunk as an IV is better, but it introduces a relation between the IV and the data that was not researched by the designers of the protocol so it might introduce a weakness too. Intuitively the relation is faint and deliberately obfuscated, but a true cryptographer must judge whether that is good enough, and then other cryptographer should critique that judgement.

3onyc commented 10 years ago

Any news on this? Filenames (and the other mentioned issues) leaking information is a major problem. And unless it's clearly mentioned when creating an encrypted library may give people a false sense of security.

patrickwolf commented 10 years ago

Your page states:

Privacy Protection

  • Deploy on your own machine
  • Encrypt files with your own password
  • Keep password only on clients

Seafile provides an advanced feature called encrypted library to protect your privacy. The file encryption/decryption is performed in the client-side. The password of an encrypted library is not stored in the server. Even the system admin of the server can't view the file contents. https://seacloud.cc/group/3/wiki/faq-for-security-features/

But as @ef4 points out above SeaFile really isn't ready to be used with sensitive material yet.

Your response is totally understandable:

Killing: But it takes a lot of effort so we don't have time to work on it currently.

BUT you need to need to state on your site that SeaFile is beta software and only rudimentary secure right now instead of making it look like it is fully secure.

Thanks!

Finkregh commented 10 years ago

kudos! @patrickwolf

fstoerkle commented 10 years ago

Is there any update on this topic? Are the issues raised by @ef4 still valid in the latest release?

Would be glad to have your insight on this.

benoitv-code commented 9 years ago

Agreed with @patrickwolf, the documentation is currently misleading regarding what to expect from Seafile on the security/privacy side.

A fair move would be to add a "Limitations" notice to the documentation.

@killing: Any update on this?

midi commented 9 years ago

Another albeit not security limitation, auto upload of photos/videos on Android is not supported for encrypted libraries https://github.com/haiwen/seadroid/issues/201

To my knowledge Seafile is still the best Open Source file syncing solution that has integrated encryption and thus no need to fiddle around with third party encryption tools, which is especially annoying on mobile.

killing commented 9 years ago

For the time being, the only thing we plan to improve is use a different salt for each encrypted library. The current version still use a static salt for all encrypted libraries. The other proposed security enhancements to encrypted libraries are not on schedule. Those includes:

We'll make these limitations clear in our documentation. The users can make their own choice.

CoolkcaH commented 9 years ago

It's much worse to have bad encryption than no encryption...and don't even try to implement security or distributed code if you are not an expert in the field. Use proven libs the recommended way only, and get the code audited. Otherwise it's worse than useless, and the users cannot make their own choice because users know nothing about security.

shuhaowu commented 9 years ago

Full encryption of file metadata, history etc. Only file content is encrypted.

Wait, are histories decrypted and stored or something? The content in the history should be encrypted as well, right?

shoeper commented 9 years ago

look at the first post. Don't think anything changed so far. And dev already commented on this 24 days ago - don't think it's that hard to read.

If you think your data is so important/confidential that it is not enough to keep it on your own hardware, don't think anyone will stop you from implementing this or hirering one to do so.

killing commented 9 years ago

Yes, file contents in the history are encrypted.

2015-02-25 4:52 GMT+08:00 Aaron Hastings notifications@github.com:

Wait, are histories decrypted and stored or something? The content in the history should be encrypted as well, right?

I certainly hope so. Can a dev comment on this?

— Reply to this email directly or view it on GitHub https://github.com/haiwen/seafile/issues/350#issuecomment-75843167.

akaho commented 9 years ago

@patrickwolf I agree.

curtiszimmerman commented 8 years ago

Holy shit. This needs to be advertised loudly in the manual and the UI. I was about to send data to S3 and decided to look into how exactly Seafile is encrypting my library contents. This is security theater. I love Seafile, but people need to know to not use this functionality if they want something secure.

kantorkel commented 8 years ago

Any news on this topic?

stevesbrain commented 8 years ago

@ef4 - Just wanted to say I appreciate the in-depth explanation you have given; very insightful to read!

killing commented 8 years ago

@kantorkel We'll update the encryption algorithm to use separate salt for each library in version 5.1 or 5.2. Other improvements proposed in this thread are not planned, as I said before. We'll make the limitation clear in our documentation.

shuhaowu commented 8 years ago

Where is the limitation section in the documentation? I cannot find it here: http://manual.seafile.com/security/security_features.html

shoeper commented 8 years ago

Which limitation? Are you talking about the metadata?

In the manual it says the following in bold characters.

Even the system admin of the server can't view the file contents.

kelson42 commented 7 years ago

This ticket seems to be a blocker for Seafile adoption in Freedombox https://wiki.debian.org/FreedomBox/LeavingTheCloud

k-ninja commented 7 years ago

So what is the status on this? The issue remains Open, but @killing has stated that there are no plans for other improvements...

I sincerely hope that the issue related to the re-use of IVs is not going to stay unfixed forever, in fact IMO moving to at least using unique IV per file/block should be one of your highest priorities, if you are serious about Seafile being used for anything other than hobby file servers.

If there's not going to be any further improvements, then this issue should be closed, so that those of us who are hoping for an improvement can look for a product which better meets our needs. If there is any intention to improve the current implementation of encrypted libraries, then it would be good to get some kind of definitive time line on when we can expect it.

instantname commented 6 years ago

Shall this ticket not be split into two (or more) separate issues: the single IV vulnerability and the unencrypted metadata/history? The first one really is a bug that should be fixed, while the second one is more of a design choice.

On the long term, I agree with other comments that even the metadata of the "filesystem" should be encrypted. If you want to claim without small prints that "Seafile uses encryption", I think some effort should be put into having full encryption of the libraries.

Chouchen commented 6 years ago

More than 4 years? Any news @killing ? Wasn't aware of this and, as much as I like Seafile, that makes me want to stop using it…

FloTheSysadmin commented 6 years ago

Will this issue ever be resolved ? I mean it's a serious problem and it's been 4 years .

stevesbrain commented 6 years ago

If an issue takes 4.5 years to solve, sadly, I'd say it's not a priority @RichardRMatthews . When security isn't a priority, I find it hard to put much faith in the project to protect secure data.

curtiszimmerman commented 6 years ago

Haha yeah, @stevesbrain totally beat me to the punch. I was thinking like man, this issue has been open for half as long as the length of the entire Apollo Program. So no, it's not going to ever be resolved.

kantorkel commented 6 years ago

see https://github.com/haiwen/seafile/issues/350#issuecomment-184094215

We'll update the encryption algorithm to use separate salt for each library in version 5.1 or 5.2. Other improvements proposed in this thread are not planned

jans23 commented 6 years ago

We have done a code audit of the Seafile's encryption in 2015 and found tons of security issues. From what I remember there were findings such as hard coded "magic" numbers, insufficient IVs, server-side generated keys, unencrypted meta data, no integrity protection, wrong/false documentation encryption features. It revealed that the developers had no interest or no skills in proper encryption. My summary: Don't trust Seafile's encryption unless you have audited Seafile's code yourself.

stevesbrain commented 6 years ago

@jans23 Out of curiosity, do you have a link to this audit we could read?

alphapapa commented 6 years ago

The fact that this issue (and the issues raised in it) remains unaddressed after nearly five years suggests that the authors are either incompetent or intentional in their insecure design. The provenance of the major contributors, and the possibility of governmental coercion, should be carefully considered as well. I suggest that this project should be considered hostile, perhaps even a honeypot, and avoided at all costs.

jans23 commented 6 years ago

@stevesbrain No, we don't have a formal report and didn't publish anything about that.

marcusmysc commented 6 years ago

@jans23 Did you inform Seafile about that?

jans23 commented 6 years ago

@marcusm1009 We didn't see a point in discussing this with Seafile team because from what we saw in the code and in tickets like this, Seafile doesn't seem to be interested in security. The worst was that they clearly stated obviously wrong facts about Seafile's encryption on the website/documentation.

shoeper commented 6 years ago

Seafile doesn't seem to be interested in security

I see something different. They aren't interested in the security of the client side encryption / encrypted libraries.

alphapapa commented 6 years ago

I see something different. They aren't interested in the security of the client side encryption / encrypted libraries.

But they're happy for users to store their sensitive, private data with them, aren't they? Gee, I wonder why...

aadrian commented 6 years ago

But they're happy for users to store their sensitive, private data with them, aren't they? Gee, I wonder why...

@alphapapa they're among the very few that allow you to install the server on your own hardware where you have the full control (and this can be even your home computer behind a NAT with DynDNS), so encryption is pretty much a non-issue there.

alphapapa commented 6 years ago

@aadrian That depends on your threat model.

aadrian commented 6 years ago

That depends on your threat model.

@alphapapa seriously? :)

Most Seafile users are just happy and grateful that they have an alternative to Dropbox et co that works on many device types too, is fast and they can own the server and data (as opposed to the many "alternatives"): this is the main use case of this application.

Being open source however, allows the many security experts around to contribute PRs for the use cases where they want to host Seafile like a service, for others: where encryption would be of course a requirement :) .

alphapapa commented 6 years ago

@aadrian I don't understand what you're getting at.

an alternative to Dropbox et co

There are open-source alternatives to Seafile.

Most Seafile users are just happy and grateful

Why did you emphasize the word "grateful"? Are you implying that we should not be complaining about security vulnerabilities? If so, that is a peculiar and dangerous attitude.

Being open source however, allows the many security experts around to contribute PRs

What? As this bug report demonstrates, Seafile's developers are not taking security seriously. Do you honestly think that the server is devoid of security flaws? Don't you think that the client having serious issues like this means that the server certainly does as well? In which case...

for the use cases where they want to host Seafile like a service

Seafile is certainly an unwise solution for those use cases.

where encryption would be of course a requirement :)

You seem to be missing a point: encryption is not the only issue. Security vulnerabilities are the issue. And the fact that the developers are not taking security seriously raises serious questions about the project as a whole. Who knows what other vulnerabilities the project might have, now or in the future. As I said, it should be carefully considered whether the project could be coerced into acting as honeypot.

If you don't care about security, fine, it's your data. Don't pooh-pooh the serious concerns others have about this project; doing so raises questions about your motivation.

shoeper commented 6 years ago

Security vulnerabilities are the issue. And the fact that the developers are not taking security seriously raises serious questions about the project as a whole.

From where do you know / infer that developers do not care about all security issues? This one is a very specific one. It does not affect the security for all users. For what I know other known security issues have been fixed within less than a week in the past.

And the reason it isn't getting fixed is quite obvious from my point of view. The professional edition customers don't use the feature. Most of them even don't want to have it, but ask for features allowing the administrator to have full control over everything. Since 5.0.1 there is even an option for the admin to fully disable encrypted libraries.

aadrian commented 6 years ago

@alphapapa

I don't understand what you're getting at.

There are several use cases for Seafile, with the main one being users that own a few devices (different types) and a personal server (or the desktop behind a NAT) and what to keep the data on them in sync (and private).

Encryption of that kind of server is not relevant in this case: what this ticket is about - so most users do not seem to be affected buy the actual poor encryption feature implementation of the server.

There are open-source alternatives to Seafile.

There are, but name only one that supports as many different clients, as easy to use, is as fast as Seafile, is still maintained and can be installed behind NAT, requires only port 443 ( -> SyncThing does not fulfill these common criteria :( ).

Why did you emphasize the word "grateful"? Are you implying that we should not be complaining about security vulnerabilities?

I'm implying that since the main use case of this application does not require Encryption, and since this ticket is about server encryption, the "outrage" does not seem to constructive here.

Do you honestly think that the server is devoid of security flaws?

Of course not, but it would be really helpful for all of us if those issues would be addressed separately (each one), since they should be fixed even if the users don't activate the encryption on their servers.

You seem to be missing a point: encryption is not the only issue.

This very ticket is however about encryption.

Security vulnerabilities are the issue.

Which ones? Please open a ticket if you are aware of them. Do you also have some sort of tests to reproduce them for the main use case this project has (since that's what most users care about)?

shoeper commented 6 years ago

@alphapapa you gave thumbs down. Could you please also tell which other security issues where not resolved and why you think security is not being taken seriously at all.

christmart commented 5 years ago

@killing We'll update the encryption algorithm to use separate salt for each library in version 5.1 or 5.2. Other improvements proposed in this thread are not planned, as I said before. We'll make the limitation clear in our documentation.

Did you ever update the encryption algorithm like you intended? There is now a CVE https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-7469 for this problem and the analysis seams to show that it is still not changed.

moschlar commented 5 years ago

@christmart It doesn't look like it:

moschlar commented 5 years ago

If we do not address this situation, the Seafile client will never be officially packaged for Debian (and thus, Ubuntu), Gentoo and probably all other distributions that care about CVEs.

killing commented 5 years ago

We'll fix the salt issue recently and include it in 7.0 version of Seafile server. Also a new version of client is needed to work with the new encrypted libraries.

killing commented 5 years ago

IMO, there is some misunderstanding in the CVE. Seafile doesn't use the same IV for every library. The IV is calculated from the library password and the salt. Even though the salt is reused in all libraries, the passwords are usually different.

What @ef4 originally stated is that the IV is reused for all the files in the same library.