server icon indicating copy to clipboard operation
server copied to clipboard

Logintoken are Invalidated 21.0.1

Open newhinton opened this issue 5 years ago • 46 comments

After updating to 21 from 20, external applications cannot access nextcloud anymore. Shortly after they were set up (Either via the Loginflow, or manually setting up tokens and inserting them in the respective app) they are getting disabled and the corresponding app is beeing logged out or recieves "Unauthorized" errors. The Logmessage is not providing a reason why a token was invalidated. The webui works as intended.

Edit: Forum

Steps to reproduce

  1. Set up new Apptoken
  2. Enter token and use it
  3. Get Unauthorized errors, and password_invalid is set to 1 in the database.

Expected behaviour

Login should not be invalidated.

Actual behaviour

Token gets immediately invalidated.

Server configuration

Operating system: Ubuntu 20.04

Web server: Apache

Database: Msql

PHP version: 7.4.3

Nextcloud version: (see Nextcloud admin page) 21.0.1.1

Updated from an older Nextcloud/ownCloud or fresh install: Updated from 20.0.9

List of activated apps:

App list
Enabled:
  - activity: 2.14.3
  - admin_audit: 1.11.0
  - apporder: 0.12.0
  - bookmarks: 4.1.0
  - bruteforcesettings: 2.1.0
  - calendar: 2.2.0
  - cloud_federation_api: 1.4.0
  - contacts: 3.5.1
  - contactsinteraction: 1.2.0
  - cookbook: 0.8.4
  - dav: 1.17.1
  - federatedfilesharing: 1.11.0
  - files: 1.16.0
  - files_pdfviewer: 2.1.0
  - files_rightclick: 1.0.0
  - files_sharing: 1.13.1
  - files_trashbin: 1.11.0
  - files_versions: 1.14.0
  - logreader: 2.6.0
  - lookup_server_connector: 1.9.0
  - notes: 4.0.4
  - notifications: 2.9.0
  - oauth2: 1.9.0
  - oidc_login: 1.7.1
  - password_policy: 1.11.0
  - photos: 1.3.0
  - previewgenerator: 3.1.1
  - privacy: 1.5.0
  - provisioning_api: 1.11.0
  - quickaccesssorting: 1.1.2
  - quota_warning: 1.10.0
  - ransomware_protection: 1.10.0
  - richdocumentscode: 6.4.705
  - settings: 1.3.0
  - sharebymail: 1.11.0
  - spreed: 11.1.2
  - text: 3.2.0
  - theming: 1.12.0
  - theming_customcss: 1.8.0
  - twofactor_backupcodes: 1.10.0
  - updatenotification: 1.11.0
  - viewer: 1.5.0
  - workflowengine: 2.3.0

Nextcloud configuration:

Config report
bruteforce is disabled

Are you using encryption: no

Are you using an external user-backend, if yes which one: Single Sign on via Keycloak

Client configuration

Nextcloud Apps (Linux Desktop and Android), DAVx5

Logs

Web server error log

Web server error log
"PROPFIND /remote.php/dav/calendars/A/B/ HTTP/1.1" 401 5669 "-" "DAVx5/3.3.9-ose (2021/02/27; dav4jvm; okhttp/4.9.1) Android/11"

Nextcloud log (data/nextcloud.log)

Nextcloud log
Warning | core | Login failed: 'X' (Remote IP: 'Y')

newhinton avatar Apr 11 '21 13:04 newhinton

Same problem as already described by newhinton. After the update to Nextcloud 21 there is a problem with the login to Nextcloud, via web browser and tokens .

Actual behaviour

Web browser login

  • Login via web interface works as usual. I use FIDO2 and TOTP which works fine via web browser.
  • After some time there is an auto log off

Third Party Apps

  • Login to web interface works fine to create tokens
  • Token creation is possible
  • Token works for some time within different third party apps, like Thunderbird, Joplin, iOS Calendar app
  • After some time the following happens
  1. automatic log out from web interface
  2. Login via previously created token is no longer possible. All connected apps show an error message.

This error exists even for older tokens which were created with an older Nextcloud version. So on all devices it is not possible to connect via Token to a Nextcloud instance.

Nextcloud Desktop-Client (Version 3.1.3) After the update to Nextcloud 21.0.1 the client lost the connection to Nextcloud. The verification via web bowser worked fine and the client got a connection again. The client lost the connection after some time to Nextcloud again.

You can go through the hole process over and over again with always the same results.

Server configuration

Operating system: Raspbian GNU/Linux 10 (buster)

Web server: Apache/2.4.38 (Raspbian)

Database: MariaDB 10.3.27

PHP version: PHP 7.3.27

Nextcloud version: Nextcloud 21.0.1

Updated from an older Nextcloud/ownCloud or fresh install: older Version of Nextcloud

Where did you install Nextcloud from: Web based update process

List of activated apps: sudo -u www-data php occ app:list

Enabled:

  • accessibility: 1.7.0
  • activity: 2.14.3
  • bookmarks: 4.1.0
  • calendar: 2.2.0
  • cloud_federation_api: 1.4.0
  • comments: 1.11.0
  • contacts: 3.5.1
  • contactsinteraction: 1.2.0
  • dashboard: 7.1.0
  • dav: 1.17.1
  • event_update_notification: 1.2.0
  • federatedfilesharing: 1.11.0
  • federation: 1.11.0
  • files: 1.16.0
  • files_pdfviewer: 2.1.0
  • files_rightclick: 1.0.0
  • files_sharing: 1.13.1
  • files_versions: 1.14.0
  • files_videoplayer: 1.10.0
  • firstrunwizard: 2.10.0
  • logreader: 2.6.0
  • lookup_server_connector: 1.9.0
  • nextcloud_announcements: 1.10.0
  • notifications: 2.9.0
  • oauth2: 1.9.0
  • password_policy: 1.11.0
  • photos: 1.3.0
  • privacy: 1.5.0
  • provisioning_api: 1.11.0
  • ransomware_protection: 1.10.0
  • recommendations: 1.0.0
  • serverinfo: 1.11.0
  • settings: 1.3.0
  • sharebymail: 1.11.0
  • survey_client: 1.9.0
  • systemtags: 1.11.0
  • tasks: 0.13.6
  • text: 3.2.0
  • theming: 1.12.0
  • twofactor_backupcodes: 1.10.0
  • twofactor_totp: 6.0.0
  • twofactor_u2f: 6.1.0
  • updatenotification: 1.11.0
  • user_status: 1.1.1
  • viewer: 1.5.0
  • weather_status: 1.1.0
  • workflowengine: 2.3.0

Are you using encryption: no

Nextcloud log

The log shows tons of such messages.

Warning core Login failed: '' Warning core Renewing session token failed

userofgithub023897 avatar Apr 11 '21 20:04 userofgithub023897

Just wanted to add that I noticed this happen only when upgrading from 21.0.0.18 to 21.0.1.1. I hope this narrows things somewhat.

daniel-odrinski avatar Apr 12 '21 19:04 daniel-odrinski

Do you have any workaround to get Android and Desktop client applications work until this is fixed ?

ririsoft avatar Apr 13 '21 07:04 ririsoft

Might it possibly have something to do with https://github.com/nextcloud/server/pull/25460 and its backport to 21.0.1 https://github.com/nextcloud/server/pull/25571?

Weasy666 avatar Apr 13 '21 07:04 Weasy666

I'm seeing the exact same behavior as userofgithub023897 on the latest Docker image, but only for LDAP-authenticated users. The LDAP setup has been working through many Nextcloud versions and all tests on the LDAP / AD Integration page are still successful. LDAP-authenticated users can log in (web and apps), but are thrown out after a couple of minutes. My recurring log entries read:

Warning user_ldap Configuration Error (prefix s01): either no password is given for the user agent or a password is given, but not an LDAP agent Warning user_ldap Bind failed: 49: Invalid credentials Warning core Login failed:

Hope it helps narrowing this down.

aeisen avatar Apr 13 '21 10:04 aeisen

im facing exactly the same behavior as @userofgithub023897 describes. (also with 21.0.1) i have enabled automatic updates so i guess it was also a small step like @DanWiseProgramming s case..

daum3ns avatar Apr 13 '21 16:04 daum3ns

I'm also seeing similar behaviour, but for me, it seems that logging into a new device which requires an app password will log me out of other devices.

i.e. I use DAVx5 and the Nextcloud app on my phone, and if I log in to one, it logs me out of the other. This also seems to reflect on my Desktop client too, where logging in there will log me out of my phone.

This doesn't appear to affect logging in via the web interface at all, as I can use that without it affecting whatever application is currently logged in.

Edit I've been able to mitigate this by logging in on my desktop client, then using the same app password for DAV and the Nextcloud app on my phone, and so far, all 3 clients appear to be working without it complaining. It looks like there's a limit to the number of active app passwords you can have somehow.

I'll update this if any of my clients decide to stop working.

agentrigby avatar Apr 13 '21 16:04 agentrigby

@agentrigby How did you extract the apppassword from the desktopclient?

newhinton avatar Apr 13 '21 17:04 newhinton

It looks like the issue only occurs for users that have log in via web interface.

Other users that haven´t logged in to Nextcloud via web browser since the update to 21.0.1 are still able to use their tokens on their devices and for their apps. At least there were no complaints about any login errors until now.

The log only shows the error messages for users that have logged in via web interface: Warning core Login failed: Warning core Renewing session token failed

userofgithub023897 avatar Apr 13 '21 18:04 userofgithub023897

@newhinton Not sure if it's allowing 2 sessions on my install, or different ways of logging in are treated differently.

I was able to login to the desktop client and use an app password for DAV without any issues, but the moment I logged in on the mobile app with my standard credentials, it broke both the desktop app and DAV.

Just been doing a bit more testing, and it seems whenever I login with a third session, it kicks the oldest one out. i.e. If I login via the web browser, it breaks the oldest session (DAV), leaving the 2 newer sessions active. When I generate a new app password, it breaks my desktop app, but leaves my web session active, then when I sign in again with my desktop app, it logs me out of my web session.

agentrigby avatar Apr 13 '21 19:04 agentrigby

Here nearly the same. There seems to be a problem with users who use security keys for login.

We have a lot of Yubico Fido2/Webauthn keys in use. ==> They are logged out of the system after a few minutes.

(Warning | core | Login failed:...)

The security keys are configured as Webauthn + U2F. This has now worked great for half a year

Users with TOTP login as 2nd factor are not affected.

This is a big problem for us as we have a number of users with Fido2 access.

osm-frasch avatar Apr 14 '21 11:04 osm-frasch

I have a smiliar issue. I started migrating my user from normal login + otp to keycloak based login via social login. I didn't realize that that users are getting logged out, but now that I've read this issue it's actually exactly like that. I do also use DAVx5 to synchronize my calendar and contacts, but whenever I use the webinterface I get logged out of DAVx5 and so on.

nolexio avatar Apr 14 '21 11:04 nolexio

I can see the same issue if I use FIDO2 for login, but there is another strange behavior. If I reconnect my desktop clients using the login flow with my password, everything is fine. If I login into the webinterface using my password, still, everything is fine. But after login with FIDO2, all clients including the web session itself is logged out after some time. If I close the desktop client before I login with FIDO2 and after a few minutes, I login with my password before I open the desktop client again the client keeps the session. So it seems that the registered sessions become valid again after a login with a password. Thus using a username and a password for login seems to circumvent the issue.

flo90 avatar Apr 14 '21 22:04 flo90

Thus using a username and a password for login seems to circumvent the issue.

For security reasons, we have coupled the login (username/password) with TOTP as a 2nd factor. These users have no problems logging in and staying logged in. Only very few in our education centre use the desktop client. For example, I had to log in again with the desktop client. This way everything works.

All users with security keys can log in but are kicked out after a few minutes. It's a drama

osm-frasch avatar Apr 15 '21 06:04 osm-frasch

Thus using a username and a password for login seems to circumvent the issue.

the problem in my case for example is, that i don't really "know" the password because its very long and random.. i mean its kept somewhere in an offline storage of course... but using username and password is not really a handy option.. and breaks my security concept... thats the whole point of the fido2 key..

daum3ns avatar Apr 15 '21 07:04 daum3ns

As described by @flo90 and @osm-frasch the error might be related to FIDO2 login procedure.

I logged in to web interface via TOTP instead of using the hardware token and created completely new tokens for my devices and apps. These newly created tokens work for hours now without any problems.

Afterwards, I logged in to Nextcloud web interface using TOTP instead of FIDO2 to check if the tokens will be set automatically invalid which is not the case.

Until now I haven´t any issues with this workaround. Everything works fine.

So maybe the problem is not directly related to Nextcloud but only to the app "Two-Factor U2F". (https://apps.nextcloud.com/apps/twofactor_u2f)

userofgithub023897 avatar Apr 15 '21 10:04 userofgithub023897

I am experiencing the same errors described by @newhinton without using TOTP or FIDO2 but OIDC and LDAP Backend.

All my app passwords became invalid after the upgrade. Newly created app passwords cannot be used ("unauthorized error"). Like @agentrigby described all the different apps that used their own app passwords stopped working.

Using different sync clients at the same time all of them are disconnected after some minutes.

@userofgithub023897 Maybe there is also an error in the app you mentioned but I don't think that the original issue is caused by this.

klatka avatar Apr 15 '21 11:04 klatka

The normal password works with clients aswell, using DavX5 with the default login-password allows the client to sync. This only works without 2FA.

newhinton avatar Apr 15 '21 11:04 newhinton

Either way,...is the solution already being taken care of? It is a big problem

osm-frasch avatar Apr 15 '21 12:04 osm-frasch

Regarding the Fido2 problem: I noticed that whenever I changed the chat room in the Talk app, I was immediately logged out. If I was not active in the other apps, e.g. file directory, I was logged out after about 2 minutes.

We have activated U2f on our security keys (Yubico) in addition to webauthn/Fido2. As a temporary solution to the problem, it helps to delete the webauthn/Fido2 authentication in the security settings of the account and only use the U2f authentication on the stick.

This then works perfectly...but does not solve the basic Fido2 problem.

osm-frasch avatar Apr 16 '21 11:04 osm-frasch