App passwords vanish
Steps to reproduce
- Enable TOTP Plugin in
- Create 2 or more App Passwords
- After some time the Desktop App starts asking for the per-device Token.
Expected behaviour
App Passwords (per-device passwords) should work infinite,
Actual behaviour
somehow the app passwords vanish from the personal menu in NC. I have to genereate a new App Password, then the Desktop Client works again.
Server configuration
Operating system: Ubuntu 16.04
Web server: Apache 2.4
Database: Mysql
PHP version: 5.6
Nextcloud version: (see Nextcloud admin page) 10.0
Updated from an older Nextcloud/ownCloud or fresh install: Updated
Where did you install Nextcloud from: NC tarball
Signing status:
Signing status
Results
=======
- core
- INVALID_HASH
- core/js/mimetypelist.js
- lib/private/Share/MailNotifications.php
- EXTRA_FILE
- resources/config/mimetypemapping.json
Raw output
==========
Array
(
[core] => Array
(
[INVALID_HASH] => Array
(
[core/js/mimetypelist.js] => Array
(
[expected] => 013e97237eeb9627ac398a50d0924621f1faa5d84ba94ab7bcc4970fbf6af55232afcf9bdef601f7f8fd6663e8e59bcb32877fd6353e893fde2c63c0893f537c
[current] => 1533e80c77d5eb738008b5c4c045ea014fe3653053c4c118e1eca267c4e56102788ed31a5d79d6041f1e639fa5ab55d060ea0035980fbb4915989a36ebcf96f0
)
[lib/private/Share/MailNotifications.php] => Array
(
[expected] => ff4d6280890f3d370907086c8f920a51674c72224ab5cf865b1ae42140ea2c614bb03cc0547a59205810d62e35a3d365925738d7983375e272acf826bce1633f
[current] => 1875a25f8593737e2e3e00b0e2ecccb14471a844922f5232275cc69ceddc144b5b6bbde350aad5f817164e390808c3c3b9ca8fe76ad6cb037e4ad7498a1a5366
)
)
[EXTRA_FILE] => Array
(
[resources/config/mimetypemapping.json] => Array
(
[expected] =>
[current] => e98fd0313bc3ced2ab0d92d87d73cf38b3104c93cafce38ebd079d2c0b419378831b9d7635df8e078dc2bd56ef7b141e78fdea6a8012c471843509cef6a427bc
)
)
)
)
List of activated apps:
App list
Enabled:
- activity: 2.3.2
- admin_audit: 1.0.0
- calendar: 1.4.0
- comments: 1.0.0
- contacts: true
- dav: 1.0.0
- documents: true
- federatedfilesharing: 1.0.1
- federation: 1.0.1
- files: 1.5.2
- files_accesscontrol: 1.1.2
- files_automatedtagging: 1.1.1
- files_pdfviewer: 0.8.1
- files_retention: 1.0.0
- files_sharing: 1.0.0
- files_texteditor: 2.1
- files_trashbin: 1.0.0
- files_versions: 1.3.0
- files_videoplayer: 0.9.8
- gallery: 15.0.0
- notifications: 0.3.0
- password_policy: 1.0.0
- provisioning_api: 1.0.0
- serverinfo: 1.1.1
- survey_client: 0.1.5
- systemtags: 1.0.2
- tasks: 0.9.3
- templateeditor: 0.1
- theming: 1.0.1
- twofactor_totp: 0.4.1
- updatenotification: 1.0.1
- user_external: 0.4
- workflowengine: 1.0.1
Disabled:
- encryption
- external
- files_external
- firstrunwizard
- user_ldap
- user_saml
The content of config/config.php:
Config report
$CONFIG = array (
'instanceid' => '',
'passwordsalt' => '',
'trusted_domains' =>
array (
0 => 'nc.niedermayr.net',
1 => 'oc.niedermayr.net',
2 => 'nct.niedermayr.net',
),
'datadirectory' => '/var/www/nc.niedermayr.net/data',
'dbtype' => 'mysql',
'version' => '9.1.0.16',
'dbname' => 'oc_niedermayr_net',
'dbhost' => 'localhost',
'dbtableprefix' => 'oc_',
'dbuser' => 'oc_niedermayr_ne',
'dbpassword' => '',
'installed' => true,
'defaultapp' => 'activity',
'theme' => '',
'maintenance' => false,
'forcessl' => true,
'secret' => '',
'mail_from_address' => 'oc',
'mail_smtpmode' => 'php',
'mail_domain' => 'niedermayr.net',
'filelocking.enabled' => 'true',
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'localhost',
0 => '/tmp/redis.sock',
'port' => 6379,
'timeout' => 0,
'dbindex' => 0,
),
'user_backends' =>
array (
0 =>
array (
'class' => 'OC_User_IMAP',
'arguments' =>
array (
0 => '{XXXX:993/imap/ssl}INBOX',
),
),
),
'loglevel' => 2,
'trashbin_retention_obligation' => 'auto',
'updater.release.channel' => 'stable',
);
Are you using external storage, if yes which one: local/smb/sftp/...
no
Are you using encryption: yes/no
no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
yes, user_external (imap)
Client configuration
Browser:
Palemoon X64 / Linux
Operating system:
Ubuntu 16.04
Logs
Web server error log
Web server error log
``` Insert your webserver log here ```Nextcloud log (data/nextcloud.log)
Nextcloud log
``` Insert your Nextcloud log here ```Browser log
Browser log
``` Insert your browser log here, this could for example include:a) The javascript console log b) The network log c) ...
</details>
Did you change your user password in the meanwhile?
No.
FYI @ChristophWurst
The only "unusual" thing is, that it's external user authentication...
@ChristophWurst is there maybe a background job which deletes tokens of deleted users and it doesn't check for the external users?
@ChristophWurst is there maybe a background job which deletes tokens of deleted users and it doesn't check for the external users?
No. We only delete old temporary tokens in the background (session tokens): https://github.com/nextcloud/server/blob/stable10/lib/private/Authentication/Token/DefaultTokenMapper.php#L50-L62 https://github.com/nextcloud/server/blob/stable10/lib/private/Authentication/Token/DefaultTokenProvider.php#L191-L193 https://github.com/nextcloud/server/blob/master/lib/private/Authentication/Token/DefaultTokenCleanupJob.php#L33 regardless of the user.
The only "unusual" thing is, that it's external user authentication...
We periodically check the password that is encoded in device password. Maybe that check fails because the external user back end is having some hiccups? What user back end are you using?
After some time
What are we talking about here? Minutes? Hours? Days? :-)
@ChristophWurst ah mmm that could explain it. But we should really be resilient against backend hickups. Mmmm of course we don't get back if it failed (timeout whatever) or really failed.
Maybe we could just add a column that says if the token is valid/invalid? Or a counter or whatever. So that we at least try a few times?
Then if a user logins in using it username and password we could check the invalidated tokens and check if they are still valid right?
@ChristophWurst c.nc.c uses LDAP.
https://github.com/owncloud/core/issues/26731 might also be related
owncloud/core#26731 might also be related Are you using an external user-backend, if yes which one: no
Interesting. If that report is correct it happens with local users too.
Do we have some reliable steps to reproduce? Otherwise it's tricky to find and verify a bugfix.
@ChristophWurst In my Installation it happens nearly daily: I create a new per-device Token, use it, and next Day the Client will ask for a password - Device pw has vanished..
I started a simply testing user backend for this purpose, but I could not yet figure out where external user backends might fail. https://github.com/ChristophWurst/user_crappy/blob/master/lib/CrappyUserBackend.php Currently we invalidate device passwords if the password check fails, because those clients should be logged out. Do we have any logs or stack traces? E.g. from the LDAP user backend?
Btw does it also happen if you disable all 2FA providers?
Some thought:
- the user sessions checks the device token periodically (~once in 5 minutes)
- it uses the user manager to check the password
- the user manager uses the registered user backends to check the password
Therefore, I assume it could also happen that for some reason the user backend is not (yet) registered when we check the token and therefore the user manager falsely fails the password check and the user session deletes the token. Again, this is just an assumption, something else could fail too.
@ChristophWurst do you try to fetch the user from a user backend? Externals might be offline at some point, for example. Or do you listen to delete hooks?
Externals might be offline at some point, for example
Do we have an mechanism to detect whether a user backend is just temporarily unavailable? That sound problematic otherwise. https://github.com/nextcloud/server/blob/b1901534be20ab768c4f5dccaa5c7c81fb472aa8/lib/private/User/Manager.php#L187-L202 will iterate over all registered backends. If one is not there temporarily, the password check will fail because the method returns false. The client code can not distinguish between "user backend not available" and "wrong password".
Or do you listen to delete hooks?
What do you mean? There's no hook involved in the token code.
Could it be related to mis-casing of the login name? We had problems with avatars and sharing related to that. If so the problem should be fixed with stable10 and master?
@ChristophWurst LDAP throws an Exception if the server is not reachable or has gone. But, what if a user was removed there by accident and restored a bit later (example scenario)? Or for instance is temporarily not available because of a buggy configuration change? Do tokens need to be removed this aggressively?