Skip to content

[Bug]: passwordsalt migration missing #34780

Description

@feanor12

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

Upgrading to 25 with a config.php that has no or an empty passwordsalt results in an error message.
There is no clear solution on how to introduce a passwordsalt setting to an older setup.

Adiddional description on discord: https://help.nextcloud.com/t/passwordsalt-missing-from-config-php/148081/2

Steps to reproduce

1.install 24
2.use a config.php without a passwordsalt
3.upgrade to 25

Expected behavior

A warning before the upgrade or migration/guide to use salted password hashes.

Possible questions:
Does setting passwordsalt make passwords unusable?
What must be done to migrate this setting?

Installation method

Community Docker image

Operating system

Other

PHP engine version

PHP 8.1

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "overwrite.cli.url": "https:\/\/nextcloud.domain.at",
        "enable_previews": false,
        "overwriteprotocol": "https",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "25.0.0.18",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "forcessl": true,
        "trusted_domains": [
            "owncloud.domain.at",
            "nextcloud.domain.at"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "nextcloud.domain.at",
        "share_folder": "\/Shared",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 0,
        "updater.release.channel": "stable",
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "AT",
        "mysql.utf8mb4": true
    }
}

List of activated Apps

Enabled:
  - activity: 2.17.0
  - admin_audit: 1.15.0
  - calendar: 4.0.1
  - circles: 25.0.0
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - contacts: 5.0.1
  - contactsinteraction: 1.6.0
  - dashboard: 7.5.0
  - dav: 1.24.0
  - deck: 1.8.0
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_external: 1.17.0
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - firstrunwizard: 2.14.0
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - nextcloud_announcements: 1.14.0
  - notes: 4.6.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - password_policy: 1.15.0
  - photos: 2.0.0
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - recommendations: 1.4.0
  - related_resources: 1.0.1
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - spreed: 15.0.0
  - support: 1.8.0
  - survey_client: 1.13.0
  - systemtags: 1.15.0
  - tasks: 0.14.5
  - text: 3.6.0
  - theming: 2.0.0
  - twofactor_backupcodes: 1.14.0
  - updatenotification: 1.15.0
  - user_status: 1.5.0
  - viewer: 1.9.0
  - weather_status: 1.5.0
  - workflowengine: 2.7.0
Disabled:
  - bruteforcesettings: 2.4.0
  - encryption
  - files_texteditor: 2.14.0
  - suspicious_login
  - twofactor_totp
  - user_ldap

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

Activity

  1. added
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Oct 24, 2022
  2. llucps commented on Oct 28, 2022

    @llucps

    It happened to me too after upgrading to Nextcloud 25

  3. szaimen commented on Oct 28, 2022

    @szaimen
    Contributor
  4. rakekniven commented on Oct 28, 2022

    @rakekniven
    Member

    Same here after upgrading from v24.0.6 to v25.0.0

    Bildschirmfoto 2022-10-28 um 17 09 19

    My original installation is very old and based on OC3. Did every update (major or minor) since then.
    Just checked my backups and there has been no passwordsalt variable set in config.php at all.

  5. rakekniven commented on Oct 28, 2022

    @rakekniven
    Member

    I just added the value to the config.php by using
    php /var/www/nextcloud/occ config:system:set passwordsalt --type=string --value=''

    But still no change.

  6. CarlSchwan commented on Oct 28, 2022

    @CarlSchwan
    Member

    try:

     php /var/www/nextcloud/occ config:system:set passwordsalt --type=string --value='ReplaceThisTest'
    

    the passwordsalt needs to be not empty

  7. rakekniven commented on Oct 28, 2022

    @rakekniven
    Member

    @CarlSchwan Ok, but setting a salt on an existing installation with users will not prevent users to login?

    Minutes ago I tried https://help.nextcloud.com/t/passwordsalt-missing-from-config-php/148081/2 and for sure this works as a workaround.

  8. FrenchHope commented on Oct 29, 2022

    @FrenchHope

    Oddly the patch doesn't work on my instance...

    edit : it works. Cache problem.

    But I can't confirm actions like updating apps, the button is greyed out (maybe a browser problem)

  9. feanor12 commented on Oct 29, 2022

    @feanor12
    Author

    What patch did you apply?

    • Set a non empty passwordsalt
    • Remove config check for passwordsalt
  10. FrenchHope commented on Oct 29, 2022

    @FrenchHope

    I removed config check for passwordsalt as described here :

    https://help.nextcloud.com/t/passwordsalt-missing-from-config-php/148081/2

    (not a bug in my browser as I thought)

    edit : it's a display bug, pressing enter works ! #34828

  11. feanor12 commented on Oct 31, 2022

    @feanor12
    Author

    As far as I understand hashes, changing the salt would invalidate them.
    Therefore, to migrate to a new salt all hashes must be updated and because this would require the actually passwords this has to be triggered by the user.

    A procedure like this might work, but I know very little about the inner workings of nextcloud:

    • Admin forces a password hash update on login
    • User uses the old/empty salt for the next login
    • The entered password value is used to generate a new hash using the new salt
    • To allow this to work for more than one user the migration has to be tracked for all users

    However, I don't know how to trigger such a password change.

    Furthermore, it could be that the hashes are also used for other things that are not user passwords, making migration more complicated.

  12. llucps commented on Nov 1, 2022

    @llucps

    Sorry but I'm still confused what the outcome of all this is,

    As far as I know I've never had passwordsalt in my config file and my Nextcloud installation is as old as the first Nextcloud version releases in 2015-2016?

    It would be great that someone could point out what needs to be done.. for the moment I just removed the passwordsalt from:

    foreach (['secret', 'instanceid', 'passwordsalt'] as $requiredConfig) { if ($config->getValue($requiredConfig, '') === '' && !\OC::$CLI && $config->getValue('installed', false)) { $errors[] = [

    But messing with the code it's not obviously a solution.

    Thanks,

  13. rakekniven commented on Nov 1, 2022

    @rakekniven
    Member

    My understanding so far:
    Old installations does not have a passwordsalt in their config.
    New ones have one.

    NC v25.0.0 is checking for it and here the trouble started for old installations.
    Workaround is to modify code.

    My question already added to a previous post is "Will setting a salt on an existing installation with users prevent these users to login?"
    If so it needs a solution.

  14. 17 remaining items

  15. knfoo commented on Nov 15, 2022

    @knfoo

    @modzilla99 thank you! It has clearly been to long ago since I have installed Nextcloud, I totally forgot about that. It has just been working to well. Now it is working again for me 🙏

  16. jejanim commented on Nov 15, 2022

    @jejanim

    Also running nextcloud in a container and got hit by this. @knfoo did you succeed yet?

  17. knfoo commented on Nov 16, 2022

    @knfoo

    @jejanim I did with these steps. Not sure if the first is needed but did it non the less.

    1. build a new container based on upstream
    FROM nextcloud:25.0.1-apache
    
    RUN sed -i "s/'secret',//g" /usr/src/nextcloud/lib/private/legacy/OC_Util.php
    
    1. Since I have persisted the data (https://github.com/nextcloud/docker#persistent-data) I needed to fix /var/www/html/lib/private/legacy/OC_Util.php from within the container, the same way with sed or editor if you prefer that. You can also do it on the host system where the location will be different.
  18. invario commented on Nov 19, 2022

    @invario
    Contributor

    Originally posted by @wolegis in #34780 (comment)

    This worked perfectly for me thanks!

  19. ccoenen commented on Nov 21, 2022

    @ccoenen

    upgrading 24 -> 25 has been the first rough update for years. Somewhat sad that this issue here is four weeks old, and it is still present in NC25.0.1.

    In my case: i set a new, random passwordsalt to my existing config, and all old logins continued to work just fine. I just wish this was either automated or there was a warning somewhere along the way.

  20. PVince81 commented on Nov 22, 2022

    @PVince81
    Member

    ah, interesting, so this is from old versions or coming from ownCloud.

    I have an instance currently on NC 24 that was migrated two years ago from OC 10 and earlier, and indeed I don't have a password salt either.

  21. added
    1. to developAccepted and waiting to be taken care of
    and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Nov 22, 2022
  22. added this to the Nextcloud 25.0.2 milestone on Nov 22, 2022
  23. CarlSchwan commented on Nov 23, 2022

    @CarlSchwan
    Member

    I gave it a try. Generated a password salt with

    base64 </dev/urandom | head -c 30

    and inserted that into /etc/webapps/nextcloud/config/config.php. To my surprise login was still possible. Changing passwords also worked.

    After that I upgraded to 25.0.1(from 24.0.6). Still logging in and changing passwords is possible.

    Meanwhile I'm pretty sure that passwordsalt is not taken into account at the moment - at least not for the Argon2ID password hashes in table oc_users. I would strongly appreciate that the Nextcloud developers enlighten the community about:

    * Why the config parameter `passwordsalt` became mandatory?
    

    Because this increase the security as it allows new password to use it. Also this caused some application (e.g end to end encryption) to fail when secretwas not set

    * Where and under which circumstances the parameter is actually used?
    

    When hashing a password and in general using the Security\Hasher service. When comparing the hash with a previous stored hash we compare with both am empty passwordsalt and an the passwordsalt set in the config.php

    * Whether there are any plans to use `passwordsalt` for the hashes in table `oc_users`?
    

    It is used already but only when setting new passwords. We don't rehash old passwords

  24. malteger commented on Nov 23, 2022

    @malteger

    @CarlSchwan if passwordsalt is actually used (again) it might also be a good idea to remove the deprecation notice in the sample config file, as this was very confusing to me at first while looking at the docs.

    The config entry has been officially deprecated in 2014 with 726626b

  25. wolegis commented on Nov 23, 2022

    @wolegis

    @CarlSchwan

    Many thanks for taking care of this issue and answering my questions.

    • Why the config parameter passwordsalt became mandatory?

    Because this increase the security as it allows new password to use it. Also this caused some application (e.g end to end encryption) to fail when secretwas not set

    • Where and under which circumstances the parameter is actually used?

    When hashing a password and in general using the Security\Hasher service. When comparing the hash with a previous stored hash we compare with both am empty passwordsalt and an the passwordsalt set in the config.php

    • Whether there are any plans to use passwordsalt for the hashes in table oc_users?

    It is used already but only when setting new passwords. We don't rehash old passwords

    I had a closer look at Security/Hasher. From what I understand your statements are not correct. Actually the passwordsalt is only used to verify very old (legacy) password hashes. These are recognised by their length of 60 characters (and absence of |). See function legacyHashVerify.

    New password hashes (anything that has |s and a preceding version marker) are verified by using PHP's function password_verify in function verifyHash without ever using the password salt.

    Hashes of new passwords are generated by applying PHP's function password_hash again without consideration of the password salt. See function hash.

    Bottom line: For new passwords passwordsalt is not taken into account. Neither when calculating the hashes, nor when verifying the password hashes. There is no fallback to verify these password hashes first with and then without the password salt. There is no security gain whatsoever when passwordsalt is set in the configuration.

    The only case when passwordsalt is taken into account is for verification of legacy password hashes of length 60 (and without any |). The enforcement of passwordsalt only makes sense in case there is at least one such password hash in table oc_users.

    Please correct me if I'm wrong.

  26. j-ed commented on Jan 23, 2023

    @j-ed
    Contributor

    @PVince81 Based on the administrator documentation and the comment in the config.sample.php file this parameter has been deprecated and should never be used by a developer anymore. I remember that I removed it from the configuration file approximately 6 years ago (Nextcloud 11.0.0) and never had problems afterwards. I wonder why it has been reactivated now but the documentation haven't been updated?!

      @deprecated This salt is deprecated and only used for legacy-compatibility,
      developers should *NOT* use this value for anything nowadays.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions