Repository navigation
Description
With Nextcloud 20, the term "Legacy encryption" was introduced. The documentation does say little about what legacy encryption is: https://docs.nextcloud.com/server/20/admin_manual/configuration_files/encryption_migration.html
I found another document, which gives hints about what could be meant: https://eprint.iacr.org/2020/1439.pdf
I run the command
occ encryption:scan:legacy-format
with output similar to this:
sudo -u www-data php /var/www/nextcloud/occ encryption:scan:legacy-format Scanning all files for legacy encryption Scanning all files for username /username/files_trashbin/files/file1.odt.d1592989576 does not have a proper header /username/files_trashbin/versions/folder1/file2.xls.v1585723230 does not have a proper header /username/files_versions/folder2/file3.xls.v1189677150 does not have a proper header
Now I got some files with inproper headers. Does my nextcloud still use legacy encryption for all files or does it use a more secure encryption? What are the differences?
When running occ encryption I also encountered a new command:
Command "encryption" is not defined.
Did you mean one of these?
encryption:change-key-storage-root
encryption:decrypt-all
encryption:disable
encryption:disable-master-key
encryption:enable
encryption:enable-master-key
encryption:encrypt-all
encryption:list-modules
encryption:migrate-key-storage-format
encryption:recover-user
encryption:scan:legacy-format
encryption:set-default-module
encryption:show-key-storage-root
encryption:status
There is no documentation about encryption:migrate-key-storage-format but an excerpt from the file /nextcloud/core/Command/Encryption/MigrateKeyStorage.php - https://fossies.org/linux/nextcloud/core/Command/Encryption/MigrateKeyStorage.php
75 ->setName('encryption:migrate-key-storage-format') 76 ->setDescription('Migrate the format of the keystorage to a newer format')
Am I supposed to use this command? I have key-type: user keys ( https://docs.nextcloud.com/server/20/admin_manual/configuration_files/encryption_details.html#key-type-user-key )
Will I still be able to use user keys after running this command, and is it save to run it?
My feature request is: please answer this questions and update the documentation of nextcloud.
Thank you very much for maintaining nextcloud! :)
Activity
Kuphi commentedon Nov 21, 2020
For the documentation record:
The command encryption:migrate-key-storage-format can not be run successfully, when your nextcloud is in maintenance mode.
user@server:/home/user# sudo -u www-data php /var/www/nextcloud/occ encryption:migrate-key-storage-format Nextcloud is in maintenance mode - no apps have been loaded Updating key storage format Start to update the keys: 4 [----->----------------------] In Manager.php line 187: Module with ID: OC_DEFAULT_MODULE does not exist. encryption:migrate-key-storage-formatYou have to turn off maintenance mode first:
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --offthen it runs smoothly, but without any notice before start. Does it not bear any risks?:
user@server:/home/user# sudo -u www-data php /var/www/nextcloud/occ encryption:list-modulesOC_DEFAULT_MODULE: Default encryption module [default*]user@server:/home/user# sudo -u www-data php /var/www/nextcloud/occ encryption:migrate-key-storage-formatUpdating key storage formatStart to update the keys:20 [============================]Key storage format successfully updatedAfter the migration, occ encryption:scan:legacy-format does still output the same files as "does not have a proper header". Am I supposed to delete those files? Can I simply rm them and then do occ files:scan? (All my files with inproper header are either in the trashbin or in the folder files_versions.
mark-orion commentedon Nov 27, 2020
Please someone explain what these "...does not have a proper header" error messages mean and how they can be fixed.
leblitzdick commentedon Dec 2, 2020
I also have the same question, can i set "encryption.legacy_format_support" to false without any problems?
BenedictBauerHHN commentedon Dec 3, 2020
I have the same output on occ encryption:scan:legacy-format of course to other files then the OP. Could it lead to problems if I set encryption.legacy_format_support to false?
developerrespig commentedon Dec 9, 2020
I would also be interested in some more information about that issue from an official side. Besides of that I just had a look into the legacy format scanner where this message is originating from (you can find the source code of that checker here: https://github.com/nextcloud/server/blob/1448b7c923d079c9616f87df3ffa52a4656ac6cc/apps/encryption/lib/Command/ScanLegacyFormat.php (I guess)).
With my limited php skills I guess it looks like these messages mean, that the check failed (because the private method returns false and the expected "All scanned files are properly encrypted. You can disable the legacy compatibility mode." doesn't get rendered). Question for me would be now: What to do about them? As far as I have seen them on my end they are only related to file versions or trash bins. But for now I just leave that configurational entry in the config.php and I guess you should do the same until someone says something different...
Hope to have something official here soon fingers crossed
Kuphi commentedon Dec 14, 2020
Can we get a comment regarding this issue?
After upgrading to NC 20.0.3, it does anew complain about old server side encryption format. I thought I already resolved this?
"Das alte serverseitige Verschlüsselungsformat ist aktiviert. Wir empfehlen, es zu deaktivieren. Für weitere Einzelheiten sehe bitte in die Dokumentation."
eckeSolutions commentedon Dec 17, 2020
In many instances the problem are old versions of files that are a few months old or even years.
Cleaning those versions with "occ versions:cleanup" removed all does “not have a proper header” errors for me.
Proceed with care!!! Might delete necessary file versions!!!
running "occ encryption:scan:legacy-format" after that tells me it is save do set encryption.legacy_format_support to false
This is not a general solution, but should work for some people with this problem (if “/versions/” is included in the file urls).
A solution to set the proper header would be nice though.
Kuphi commentedon Dec 17, 2020
Proceed with care? "occ versions:cleanup" does delete ALL previous versions of all files. This is only a solution if you do not need any previous versions at all.
eckeSolutions commentedon Dec 17, 2020
Yes, that’s why I added 3 exclamation marks. In my instance it was no problem. And to be on the save side I have daily backups of everything.
DPTJKKVH commentedon Dec 17, 2020
It is really sad that nobody of the team even acknowledges that
encryption:migrate-key-storage-formatis undocumented and elaborates in a few words what it does and if we should do it after disabling legacy encryption.Also @developerrespig seems to be correct. I removed the bad header files manually, ran the check, got the "you can disbale legacy encryption" message and did just that.
I see neither issues nor changes so far which is good. But it drives me nuts that I don't see the point and don't know if we should migrate the storage format because it seems to be security related.
@schiessle @rullzer @nickvergessen can you please explain if we should run
encryption:migrate-key-storage-formator not after disabling legacy encryption, even if you don't feel to explain it any further? Just a YES or NO is sufficient for the time being.Many thanks in advance!
thomwiggers commentedon Dec 21, 2020
I don't think
encryption:migrate-key-storage-formatsolves this problem. There doesn't seem to be any migration option if I look in the source code of the Encryption module.DPTJKKVH commentedon Dec 21, 2020
Well I can report that disabling legacy encryption breaks my installation, even though the encryption:scan:legacy-format tells me I can disable it.
To be more specific: Encrypted files cannot be downloaded anymore via web GUI and sharing files (e.g. publicly) doesn't work as well.
The GUI tells me that my private key is missing and I should log out and back in. But that doesn't fix it.
Then it tells me to set a new password. When changing paswords it tells me again that my private key is missing and I should log out and back in. Doing that again doesn't fix it.
So neither logging in nor changing passwords works.
Fortunately just enabling legacy encryption fixes the issue and I can access all files again. However this foreshadows doom for when legacy encryption won't be supported anymore.
Either the scanning tool is broken or there is an important step missing after or before disabling legacy encryption.
I find it rather odd that simply disabling legacy encryption in the config is supposed to change encryption schemes. Also the "has been migrated" boolean in config.php is suggesting there might be more to it.
Oh btw: The encryption:migrate-key-storage-format does not run through and produces and error about an expexted boolean value for decrypt.
thomwiggers commentedon Dec 21, 2020
It's not unlikely that the files need to be migrated from the client side if you're using user key encryption. I only have a single user, and managed to migrate by
touch-ing the few affected files. This triggered a re-upload in the client. This does however still leave old versions infiles_versionsthat now show up in the scan tool.I don't think the tool is broken, there simply isn't any migration path yet.
70 remaining items
ajs124 commentedon Feb 7, 2022
In my case, the files are just plain unencrypted files, in the filesystem. Nextcloud however seems to think that they are encrypted. I've already run
occ files:scan --alland so on, butencryption:scan:legacy-formatstill finds the same files.I fixed this by deleting the folders and files relating to those files from
files_encryption/keys, dropping the entries referencing them from the database and setting theencryptedfield to0in the database. Then I ranfiles:scan --allagain and now it seems to work. Idk if that helps anyone here.PVince81 commentedon Apr 14, 2022
for the case of unencrypted files wrongly detected as encrypted, please run: https://docs.nextcloud.com/server/latest/admin_manual/issues/general_troubleshooting.html#problems-when-downloading-or-decrypting-files
Gajusbonus commentedon Aug 18, 2022
Returns:
Command "encryption:fix-encrypted-version" is not defined.
occ config:system:get version
20.0.10.1
So....what version do you expect me to run, to be able to fix decrypting files?
RedKage commentedon Nov 27, 2022
Do you guys a favor and stop using encryption. This is broken since I have ever used nextcloud.
And started with version 9 or 10.
All these years I had 500 errors with bad encryption errors, had to re-up files to fix these issues.
For 4 years I coped with this, until version 21 or something.
Then decided to reinstall everything, re-upload everything without encryption and do my own encryption with gocrypt-fs. I'm never going back. This is a broken feature from the start. And also prevent many apps to work with it, like the music app which tries (tried? Maybe fixed) to save tags on encrypted files and corrupt them or many other apps not handling encryption.
Also now that I have removed encryption it's very easy for to backup and restore my data, as the data is unencrypted I can pull files directly from a backup. While still benefiting from fs encryption on top.
Anyway my 2cents guys.
Pazu commentedon Nov 5, 2023
Hear, hear. The worst part is there is no apparent will or perhaps even ability on the part of the developers to do anything about this problem.
asheroto commentedon Nov 29, 2023
Even on a brand new nextcloud installation the issue exists. If it's broken, it should be disabled and not offered as a working product. Related to #8546.
Going to try the solution @RedKage proposed.
Flonky commentedon Jan 11, 2024
Hi, running
./occ encryption:fix-encrypted-version userseems to have fixed this for me, although I also had to run./occ files:scan --allafterwards.For reference,
occ config:system:get versionreturns28.0.1.1.asheroto commentedon Jan 11, 2024
Indeed, it will appear to fix it at first. But I found several days later that encryption was still broken for new or changed files moving forward, especially larger than a few KB even though running that command fixes the existing files.
This of course may not be the case for everyone, but when using the previously mentioned encrypted method encryption with S3, I found this to be the case.
Flonky commentedon Jan 14, 2024
Even after key migration? I haven't noticed anything like that yet, although my instance doesn't have too much traffic either.
asheroto commentedon Jan 18, 2024
Yes! Even after that. I worked on this for days and made several posts. :-/ I ended up just switching to SSE with my S3 provider. That worked out fine, although it still rubs me the wrong way that my data is sent to the S3 provider without being encrypted first. I realize it is encrypted in transmit, but the S3 provider technically receives the raw data, then encrypts it at rest. 😊
brotkastn commentedon Jul 25, 2024
Hello everyone.
Since there have been some time since the last comment here, i thought i would take my chance again at disabling the legacy encryption.
Previously, i did the
encryption:migrate-key-storage-format. Today i have taken the following steps:However, if i try to access a share my wife made with a collection of family photos, via the link she used to send to our extended family, it seems to miss the legacy encryption. I can view the previews of the photos, but nextcloud throws an error when i try to access stuff. Neither the "Download" button on the top of the page or the download of an individual image seems to work. The nextcloud log shows the following entries:
I do wonder why that exact folder still relies on legacy encryption, as said pictures have been uploded around may - the "active" encryption-module was already set to the default one.
I wonder what the way forward to disabling the legacy encryption module is. The re-download and start with a fresh nextcloud approach is a bit problematic since we are talking about 1.2TB worth of files, family spread across a few thousand kilometers and a huge number of share links which would be lost:
Thanks for reading. I am happy that the community proved so helpful for people trying to get their data back. If there is someone with an idea how to proceed in my case, i am happy to test even more 'creative' solutions to this problem and report back.
Also, thanks to the devs for the awesome suite of software that nextcloud is :)
susnux commentedon Nov 30, 2026
Thanks for raising this. The admin manual now covers the legacy encryption format: how to check for it with
occ encryption:scan:legacy-format, when to setencryption.legacy_format_supportto false, and theencryption:migrate-key-storage-formatandencryption:drop-legacy-filekeycommands (nextcloud/documentation#14560). Problems with "invalid private key" after disabling legacy support are tracked in #8546, so I'm closing this one.