server icon indicating copy to clipboard operation
server copied to clipboard

Server repeatedly fill disk with infinite log messages: "hash_hmac(): Unknown hashing algorithm:sha1"

Open smkent opened this issue 8 years ago • 26 comments

I am not sure if this is a problem in the server or the Android app. My Nextcloud server intermittently generates these log messages within data/nextcloud.log . Once the server starts generating these messages, they're logged repeatedly as fast as the server can generate them until the partition containing the log file runs out of disk space:

{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
[repeat until disk is full]

This does not seem to occur as a result of taking any sort of action, and these log messages are not preceded by any other log messages.

Steps to reproduce

  1. Install Nextcloud server
  2. Install Android app, connect it to server, possibly enable+configure instant photo uploads (the only thing I use the app for)
  3. ???
  4. Nextcloud server sometimes starts generating repeating log messages like the above and doesn't stop until the partition containing data/nextcloud.log becomes full

Expected behaviour

The Nextcloud server should not generate repeated log messages that fill up the disk

Actual behaviour

The Nextcloud server frequently (every other day or so) frequently consumes my entire disk with the above log messages and I have to truncate the log file

Server configuration

Operating system: Gentoo Linux

Web server: Apache 2.4.29-r1

Database: MySQL 5.6.39

PHP version: PHP 7.1.15

Nextcloud version: 13.0.0

Updated from an older Nextcloud/ownCloud or fresh install: Upgraded from previous versions, I have installed each major release. This issue has been present since at least 12.0.0 and I believe in prior major releases too.

Where did you install Nextcloud from: Operating system repository

Signing status:

Signing status
Technical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.

Results
=======
- core
	- EXTRA_FILE
		- .webapp-nextcloud-13.0.0

Raw output
==========
Array
(
    [core] => Array
        (
            [EXTRA_FILE] => Array
                (
                    [.webapp-nextcloud-13.0.0] => Array
                        (
                            [expected] => 
                            [current] => 
                        )

                )

        )

)

List of activated apps:

App list
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
Enabled:
  - activity: 2.6.1
  - bruteforcesettings: 1.0.3
  - comments: 1.3.0
  - dav: 1.4.6
  - federatedfilesharing: 1.3.1
  - federation: 1.3.0
  - files: 1.8.0
  - files_pdfviewer: 1.2.0
  - files_sharing: 1.5.0
  - files_texteditor: 2.5.1
  - files_trashbin: 1.3.0
  - files_versions: 1.6.0
  - files_videoplayer: 1.2.0
  - firstrunwizard: 2.2.1
  - gallery: 18.0.0
  - logreader: 2.0.0
  - lookup_server_connector: 1.1.0
  - nextcloud_announcements: 1.2.0
  - notifications: 2.1.2
  - oauth2: 1.1.0
  - password_policy: 1.3.0
  - provisioning_api: 1.3.0
  - serverinfo: 1.3.0
  - sharebymail: 1.3.0
  - survey_client: 1.1.0
  - systemtags: 1.3.0
  - theming: 1.4.1
  - twofactor_backupcodes: 1.2.3
  - updatenotification: 1.3.0
  - user_ldap: 1.3.1
  - workflowengine: 1.3.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - user_external

Nextcloud configuration:

Config report
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "<redacted_domain>"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbtype": "mysql",
        "version": "13.0.0.14",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "<redacted_table_prefix>",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "installed": true,
        "ldapIgnoreNamingRules": false,
        "mail_smtpmode": "sendmail",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 2,
        "maintenance": false,
        "htaccess.RewriteBase": "\/",
        "ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory"
    }
}

Are you using external storage, if yes which one: No

Are you using encryption: No

Are you using an external user-backend, if yes which one: LDAP

LDAP configuration (delete this part if not used)

LDAP config
I would need to redact most, if not all, of my LDAP configuration. Please tell me if specific values are needed to diagnose.

Client configuration

Browser: Nextcloud Android app

Operating system: Android

Logs

Web server error log

Web server error log

Every 10 minutes, I have a chunk of these:

<IP_redacted> - <user_redacted> [18/Apr/2018:00:45:13 -0700] "GET /nextcloud/index.php/204 HTTP/1.1" 204 - "-" "Mozilla/5.0 (Android) ownCloud-android/3.1.0"
<IP_redacted> - <user_redacted> [18/Apr/2018:00:45:13 -0700] "GET /nextcloud/index.php/204 HTTP/1.1" 204 - "-" "Mozilla/5.0 (Android) ownCloud-android/3.1.0"
<IP_redacted> - <user_redacted> [18/Apr/2018:00:46:37 -0700] "GET /nextcloud/index.php/204 HTTP/1.1" 204 - "-" "Mozilla/5.0 (Android) ownCloud-android/3.1.0"
<IP_redacted> - <user_redacted> [18/Apr/2018:00:46:38 -0700] "GET /nextcloud/index.php/204 HTTP/1.1" 204 - "-" "Mozilla/5.0 (Android) ownCloud-android/3.1.0"

There is no other diagnostic information in the Apache access or error logs.

Nextcloud log (data/nextcloud.log)

Nextcloud log
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
{"reqId":"Wtb33eq@fRrbDOPQpXZjvQAAAEQ","level":3,"time":"2018-04-18T07:59:38+00:00","remoteAddr":"<IP redacted>","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm:sha1 at \/var/www/localhost/htdocs\/nextcloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.1.0","version":"13.0.0.14"}
[repeat until disk is full]

Browser log

Browser log

N/A, unless I can somehow get logging details from the Android app

smkent avatar Apr 19 '18 03:04 smkent

I should note the only seemingly-relevant information I found while searching around was this: https://help.nextcloud.com/t/unknown-hashing-algorithm-sha1/1031

However, I have enabled USE=mhash in my PHP installation and the issue still occurs.

smkent avatar Apr 19 '18 03:04 smkent

i have the exact same problem - disabling opcache is a workaround for me but not a solution as it comes with a performance hit. using php 5.6 also does not result in this error.

podkilla avatar May 10 '18 10:05 podkilla

After some digging, it appears that this issue may be a result of non-thread-safe PHP code entering into a bad state when executed under a multithreaded environment (such as with Apache 2.4's event MPM, which I am using). There is a generic mention of potential multithreading issues with various Apache MPMs here: https://wiki.apache.org/httpd/PHP-FPM

Based on this information, I installed PHP-FPM and configured Apache to use it instead of just mod_php by itself. It's been about a week since I migrated to PHP-FPM, and I've been making decent use of my Nextcloud app's auto upload. This issue has not occurred since I migrated.

For anyone finding this via Google, note that to make Nextcloud login work properly with PHP-FPM I also had to configure Apache to preserve the authorization information using mod_rewrite and the following configuration:

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

smkent avatar May 11 '18 18:05 smkent

I've got the exact same problem. I have a Debian 7 system and upgrading from Apache 2.4.25 to 2.4.29 causes the MPM to change from worker to event. I've just tried re-compiling with the worker MPM (which worked previously), so we'll see what happens.

terrytibbles avatar Jun 21 '18 03:06 terrytibbles

It's been a while since I migrated to PHP-FPM and the issue still has not returned.

smkent avatar Jun 21 '18 04:06 smkent

for me the problem went away after migrating from apache to nginx and php-fpm

podkilla avatar Jun 21 '18 05:06 podkilla

@jospoortvliet Is the worker MPM in Apache a known requirement? Is it worth adding it to the documentation?

terrytibbles avatar Jul 10 '18 10:07 terrytibbles

@terrytibbles I haven't verified this myself but it is worthwhile doing a quick pr to the docs to let someone there look at it :smile_cat:

jospoortvliet avatar Jul 30 '18 18:07 jospoortvliet

I am having the same problem also on gentoo. Unfortunately migrating apache mpm from event to worker did not mitigate the issue.

meskal avatar Jul 31 '18 10:07 meskal

Since phpseclib's docs suggest that bcmath and gmp might also be useful I tried various combinations of these useflags for php without success and also ended up migrating to php-fpm.

meskal avatar Aug 10 '18 13:08 meskal

Did php-fpm fix it?

jospoortvliet avatar Aug 10 '18 13:08 jospoortvliet

Unfortunately I am not able to deterministically reproduce the issue. Therefore I have to wait to verify its absence. Up until now (~24h) php-fpm seems to mitigate the issue however it also happend that it did not come up for several days before.

I'll keep you informed.

meskal avatar Aug 11 '18 18:08 meskal

This very same problem started for us with PHP 7.2.8, mod_php and Apache 2.4.34 compiled with event MPM (which we are using since early Apache 2.4 without any problems).

Reverting back to PHP 7.2.7 mitigates the issue.

Now PHP 7.2.9 was released. First I compiled it with mod_php but after a short while those "hash_hmac(): Unknown hashing algorithm: sha1 ..." messages flooded the nextcloud.log again (sometimes the error messages also read "hash(): Unknown hashing algorithm: sha512").

As suggested in this thread I switched from mod_php to PHP-FPM.

Unfortunately this does not bring any remedy to the problem but this morning the "Unknown hashing algorithm" messages had started again.

I will revert back to PHP 7.2.7 since with 7.2.7 the server runs just smooth without any problems.

Worth mentioning that whenever this happens after a while all connections to MySQL are starting to fail. MySQL eventually starts to block all connections regardless of the sources (also non-php connections). A restart of Apache brings remedy for a while.

Server configuration: Operating system: Ubuntu 18.04.1 LTS Web server: Apache 2.4.34 using HTTP/2 Database: MySQL 5.7.23 Redis 4.0.11 with PHP-module redis-4.1.1 APCU 5.1.12 PHP OPcache ON PHP version: PHP 7.2.8 and PHP 7.2.9 Nextcloud version: 13.0.5.2

Tamsy avatar Aug 20 '18 01:08 Tamsy

I think this is a problem with memory. Despite having a reasonable amount of physical memory available and little swap, setting Nextcloud to use APCu seems to cause these problems. This is especially bad under high load, when the server can crash (go to 100% CPU) at regular intervals.

I've currently mitigated this problem by setting Nextcloud not to use APCu and using the worker MPM, which is a lot more stable on my system. I'm currently monitoring the performance, but it's been pretty stable so far.

terrytibbles avatar Jan 26 '19 05:01 terrytibbles

I also had endless messages "hash (): Unknown hashing algorithm: sha512" in the log and the CPU load is 100% until you restart the Apache. I was enable php opcache according to the instructions. For a week there was no problem.

ion-lane avatar Feb 02 '19 13:02 ion-lane

https://github.com/nextcloud/server/issues/12722 looks similar.

kesselb avatar Feb 02 '19 15:02 kesselb

Has this problem been fixed in nextcloud 14?

I had always had this problem when trying to upgrade from php5 to php7 so I gave up with php7 until it was really necessary. I upgraded to php 7.2.15 yesterday and now after 24 hours apache is at 100% CPU and nextcloud.log is filling up with

{"reqId":"es7zXOVWCYYAXXkB39gK","level":3,"time":"2019-03-06T12:39:49+00:00","remoteAddr":"128.128.141.154","user":"--","app":"PHP","method":"PROPFIND","url":"\/owncloud\/remote.php\/webdav\/","message":"hash_hmac(): Unknown hashing algorithm: sha1 at \/var\/www\/htdocs\/owncloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.5.0","version":"13.0.12.1"}
{"reqId":"CrwdZmCcew4msqf00D62","level":3,"time":"2019-03-06T12:39:49+00:00","remoteAddr":"128.128.141.154","user":"--","app":"PHP","method":"GET","url":"\/owncloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm: sha1 at \/var\/www\/htdocs\/owncloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.5.0","version":"13.0.12.1"}
{"reqId":"CrwdZmCcew4msqf00D62","level":3,"time":"2019-03-06T12:39:49+00:00","remoteAddr":"128.128.141.154","user":"--","app":"PHP","method":"GET","url":"\/owncloud\/index.php\/204","message":"hash_hmac(): Unknown hashing algorithm: sha1 at \/var\/www\/htdocs\/owncloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.5.0","version":"13.0.12.1"}
{"reqId":"es7zXOVWCYYAXXkB39gK","level":3,"time":"2019-03-06T12:39:49+00:00","remoteAddr":"128.128.141.154","user":"--","app":"PHP","method":"PROPFIND","url":"\/owncloud\/remote.php\/webdav\/","message":"hash_hmac(): Unknown hashing algorithm: sha1 at \/var\/www\/htdocs\/owncloud\/3rdparty\/phpseclib\/phpseclib\/phpseclib\/Crypt\/Hash.php#308","userAgent":"Mozilla\/5.0 (Android) ownCloud-android\/3.5.0","version":"13.0.12.1"}

I can't login to nextcloud from any client without restarting apache. The android device is using the latest version of the nextcloud app.

I am currently using nextcloud 13.0.12 but want to update to 14.0.8 when I know php7 is working properly.

af7567 avatar Mar 06 '19 12:03 af7567

We only got rid of the problem by compiling Apache with mpm=worker (instead of mpm=event) and by enabling PHP-FPM. Since then those problems are gone.

Tamsy avatar Mar 06 '19 12:03 Tamsy

We only got rid of the problem by compiling Apache with mpm=worker (instead of mpm=event) and by enabling PHP-FPM. Since then those problems are gone.

Ok, thanks. I saw about using php-fpm instead, and also in #12722 that upgrading to nextcloud 15 may have fixed it. So I will give it a try with nextcloud 15 and see how it goes, then change to php-fpm if I need to.

af7567 avatar Mar 06 '19 13:03 af7567

Seems that PHP 7.3 may be a solution, too.

terrytibbles avatar Mar 07 '19 02:03 terrytibbles