Skip to content

Android App automatically logs out after few hours of inactivity #1964

Closed

Description

@johnkj

Actual behaviour

The latest version of android app 2.3.0 with little customization installs as usual but:
1-when connected to an account on owncloud 10 with php 7/7.1/5.6 automatically logs out after few hours of inactivity on the app and after that even if you give the correct password it will not login unless you uninstall the app and reinstall it.
2-When connected to an account on owncloud 9.1.0 with php 5.6/5.5 it does not log out.
This occurs when the app is installed from playstore only, this does not happen when installed directly.

Expected behaviour

Once logged into the app, it should remain logged in.

Steps to reproduce

  1. Build owncloud android 2.3.0 with basic changes in logo and setup.xml
  2. upload to playstore and install on android phone from playstore
  3. Add owncloud account which is running on OC 10 and another account running on OC 9.1.0
    4- It will login successfully, and after few hours about 3-4 hours of inactivity.
    5- Open the owncloud android app, it will logout and redirect to login screen with server url and username prefilled asking you to enter the password
    6- Even if you enter the correct password it will not accept.
    7-But adding a new account with different username will work.

Can this problem be reproduced with the official owncloud server?
(url: https://demo.owncloud.org, user: test, password: test)

Environment data

Android version: 6.0.1, 5.1

Device model:

Stock or customized system:

ownCloud app version: 2.3.0

ownCloud server version: 10.0.0.12

Logs

Web server error log

Insert your webserver log here
42.109.141.168 - testyg [12/May/2017:10:30:00 +0000] "GET /ocs/v1.php/cloud/capabilities?format=json HTTP/1.1" 200 4662 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - testyg [12/May/2017:10:30:00 +0000] "GET /ocs/v1.php/cloud/user?format=json HTTP/1.1" 200 864 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - testyg [12/May/2017:10:30:01 +0000] "GET /index.php/avatar/testyg/256 HTTP/1.1" 200 784 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - testyg [12/May/2017:10:30:01 +0000] "PROPFIND /remote.php/webdav/ HTTP/1.1" 401 811 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - - [12/May/2017:10:30:01 +0000] "GET /status.php HTTP/1.1" 200 1183 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - - [12/May/2017:10:30:01 +0000] "PROPFIND /remote.php/webdav/ HTTP/1.1" 401 1315 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - - [12/May/2017:10:30:02 +0000] "GET /status.php HTTP/1.1" 200 1183 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"
42.109.141.168 - - [12/May/2017:10:30:02 +0000] "PROPFIND /remote.php/webdav/ HTTP/1.1" 401 1309 "-" "Mozilla/5.0 (Android) owncloud-android/2.3.0"

#### ownCloud log (data/owncloud.log)
``
Insert your ownCloud log here
{"reqId":"XNTwmVMw6Qnm8cHhHwfj","level":0,"time":"2017-05-12T16:00:01+05:30","remoteAddr":"42.109.141.168","user":"testyg","app":"webdav","method":"PROPFIND","url":"\/remote.php\/webdav\/","message":"Exception: {\"Message\":\"HTTP\\\/1.1 401 CSRF check not passed.\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\NotAuthenticated\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/html\\\/backup\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Auth.php(146): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Auth->auth(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#1 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php(202): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Auth->check(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php(150): Sabre\\\\DAV\\\\Auth\\\\Plugin->check(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#3 [internal function]: Sabre\\\\DAV\\\\Auth\\\\Plugin->beforeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#5 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(466): Sabre\\\\Event\\\\EventEmitter->emit('beforeMethod', Array)\\n#6 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#7 \\\/var\\\/www\\\/html\\\/backup\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(63): Sabre\\\\DAV\\\\Server->exec()\\n#8 \\\/var\\\/www\\\/html\\\/backup\\\/remote.php(165): require_once('\\\/var\\\/www\\\/html\\\/b...')\\n#9 {main}\",\"File\":\"\\\/var\\\/www\\\/html\\\/backup\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Auth.php\",\"Line\":211,\"User\":\"testyg\"}"}
{"reqId":"p1Ry9EjrauB8MP8rPi3t","level":0,"time":"2017-05-12T16:00:01+05:30","remoteAddr":"42.109.141.168","user":"--","app":"webdav","method":"PROPFIND","url":"\/remote.php\/webdav\/","message":"Exception: {\"Message\":\"HTTP\\\/1.1 401 No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured, No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\NotAuthenticated\",\"Code\":0,\"Trace\":\"#0 [internal function]: Sabre\\\\DAV\\\\Auth\\\\Plugin->beforeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#1 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#2 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(466): Sabre\\\\Event\\\\EventEmitter->emit('beforeMethod', Array)\\n#3 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/var\\\/www\\\/html\\\/backup\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(63): Sabre\\\\DAV\\\\Server->exec()\\n#5 \\\/var\\\/www\\\/html\\\/backup\\\/remote.php(165): require_once('\\\/var\\\/www\\\/html\\\/b...')\\n#6 {main}\",\"File\":\"\\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php\",\"Line\":168,\"User\":false}"}
{"reqId":"NZ8NSNFjMoZOo8iWUd51","level":0,"time":"2017-05-12T16:00:02+05:30","remoteAddr":"42.109.141.168","user":"--","app":"webdav","method":"PROPFIND","url":"\/remote.php\/webdav\/","message":"Exception: {\"Message\":\"HTTP\\\/1.1 401 No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured, No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\NotAuthenticated\",\"Code\":0,\"Trace\":\"#0 [internal function]: Sabre\\\\DAV\\\\Auth\\\\Plugin->beforeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#1 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#2 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(466): Sabre\\\\Event\\\\EventEmitter->emit('beforeMethod', Array)\\n#3 \\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#4 \\\/var\\\/www\\\/html\\\/backup\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(63): Sabre\\\\DAV\\\\Server->exec()\\n#5 \\\/var\\\/www\\\/html\\\/backup\\\/remote.php(165): require_once('\\\/var\\\/www\\\/html\\\/b...')\\n#6 {main}\",\"File\":\"\\\/var\\\/www\\\/html\\\/backup\\\/lib\\\/composer\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php\",\"Line\":168,\"User\":false}"}

Activity

  1. DaanTry commented on Dec 21, 2017

    @DaanTry

    I have exact the same issue.

    Android version: 7.0
    Device model: SM-G935F
    Stock or customized system: Stock
    ownCloud app version: 2.5.0
    ownCloud server version: 10.0.4 (on PHP 7.0.16)

    Only removing and reinstalling App from Appstore resolves the issue.

  2. jensd0e commented on Dec 21, 2017

    @jensd0e

    I guess, this isn't a new issue. Some people (including me) reported this before. Adding me here to get status-updates.

  3. jesmrec commented on Jan 9, 2018

    @jesmrec
    Member

    we have the following opened with the same issue:

    #1964

    We can keep on discussing there. If you think is a different issue, please reopen

  4. davigonz commented on Jan 10, 2018

    @davigonz
    Contributor

    @jensd0e , @jesmrec are you sure this is the same issue that #2030?

    @johnkj Are you using LDAP? Are you using spaces in your username? Do you notice this behaviour described by @jensd0e in the other issue?

    Username is changed from 'Firstname Lastname' to 'Firstname_Lastname' and the username field can't be modified, so the username can't be changed and the user can't authenticate against LDAP server.

  5. jesmrec commented on Jan 10, 2018

    @jesmrec
    Member

    that issue refers directly to ldap or blanks but i mean that the problem is not in this set-up. Bug appears regardless LDAP is enabled or not

  6. jensd0e commented on Jan 10, 2018

    @jensd0e

    @davigonz I'm not that sure anymore. There where two problems. Username normalization and being redirected to login screen. If username normalization would cause my problems, I would see logon errors on my windows server. But for me, logon is ok and only after login I'm redirected to login screen. In #2030 I started with problem No. 1 (username normalization) and continued with problem No. 2 (being redirected). That was a bad idea, I guess.

  7. jesmrec commented on Jan 10, 2018

    @jesmrec
    Member

    ok, we reopen and keep the discussion alive

  8. DaanTry commented on Jan 10, 2018

    @DaanTry

    In my case no spaces in de username and no LDAP used for authentication. Reproducability is 100%. A few days after installing the issue appears and can only be resolved by uninstalling/reinstalling the app.

  9. davigonz commented on Jan 15, 2018

    @davigonz
    Contributor

    Hi @DaanTry , thank you for your feedback, can you create a test account and send us the credentials to [email protected] so that we can try to reproduce it? Thanks

  10. jesmrec commented on Jan 15, 2018

    @jesmrec
    Member

    @DaanTry if you send the credentials, please include a link to this issue within the email.

  11. jesmrec commented on Jan 15, 2018

    @jesmrec
    Member

    @DaanTry credentials received, thanks a lot!!!!

  12. gfredericks commented on Jan 16, 2018

    @gfredericks

    This has been happening to me for a week or two now. It also seems to always take exactly two logins to get it working, for some reason.

  13. 15 remaining items

  14. PVince81 commented on Jan 25, 2018

    @PVince81

    @davigonz it was neither SAML nor OAuth. Just the plain old password entry, probably basic auth. I don't have oauth enabled on our server.

    Is the Android client sending the CSRF request header with basic auth ? I don't see why it would we needed for basic auth.

  15. davigonz commented on Jan 25, 2018

    @davigonz
    Contributor

    Is the Android client sending the CSRF request header with basic auth ? I don't see why it would we needed for basic auth.

    @PVince81 I do not see CSRF header in our requests, at least in the login ones I described above. I will send you the logs of the login flow with the headers and content for the requests/responses, maybe you notice something weird there.

  16. PVince81 commented on Jan 25, 2018

    @PVince81

    Let's look at the server code: https://github.com/owncloud/core/blob/v10.0.4/apps/dav/lib/Connector/Sabre/Auth.php#L166

    These are the conditions that would trigger a CSRF check for any DAV call:

    • method is not GET
    • user agent is neither desktop, android or ios
    • user is logged in
    • method is POST
    • user is not "DAV authenticated" (not clear what this means, possibly that the user got authenticated over Webdav, not web UI)

    Now I wonder whether we really need a CSRF check for PROPFIND... Probably not. (to be discussed separately)

    The core problem is likely due to some of these conditions not met in that non-reproducible scenario.

  17. PVince81 commented on Jan 25, 2018

    @PVince81

    ohhh... this "DAV authenticated" condition is based on a session variable.

    It is possible that the session was in a weird state: the user was still logged in (because if isLoggedIn() is false, the CSRF check is cancelled) but not DAV authenticated, maybe the session value is gone ?

    Maybe something happened to the session and/or the app token during the upgrade.

    I have the feeling that this is related to a zombie session / zombie token, basically something that isn't cleared properly.

  18. PVince81 commented on Jan 25, 2018

    @PVince81

    And yet another little issue: as I said above, this CSRF check should never kick in for Android users.
    We do see a user-agent check in the server code.

    However my wife's user-agent says "ownCloudBeta-android/2.5.1-beta.1" but this is the server check:

    	const USER_AGENT_OWNCLOUD_ANDROID = '/^Mozilla\/5\.0 \(Android\) ownCloud\-android.*$/';
    

    I also wonder whether other users in this ticket were using a different or branded version where the user agent did not match ?

    So I think we have three issues here:

    1. User-Agent check does not correctly match all Android clients: it does not match the beta => Fix user agent of beta #2098
    2. Some weird in-between authentication/session situation that could cause CSRF for non-Android clients, possibly related to wronglyinvalidated app passwords: [10.0.4] Sessions created from application passwords result in "Login failed" errors when used core#30157
    3. Do we really need CSRF for PROPFIND ? I thought it only applies to POST... to be verified => Webdav: only check CSRF for POST core#30279
  19. DaanTry commented on Jan 26, 2018

    @DaanTry
  20. PVince81 commented on Jan 26, 2018

    @PVince81

    @DaanTry are you using the beta client or a branded client ? Are you able to find the user-agent of your client from the access logs ?

    From my analysis above, if the Android client is properly detected by the server it should never trigger the code path for CSRF check.

  21. davigonz commented on Jan 26, 2018

    @davigonz
    Contributor

    @PVince81 Thank you for the research

    @DaanTry is using 2.5.0, as he commented in #1964 (comment), so CSRF shouldn't been triggered because of user-agent not being matched.

    Other users such as @jensd0e and @pjao reported here the same redirection to login page with 2.5.0 beta 2 and 2.5.1-beta.1 respectively so it's most likely that those redirections appear because as you said above, the user-Agent check doesn't match the beta one and is triggering the CSRF check, which fails.

  22. DaanTry commented on Jan 26, 2018

    @DaanTry
  23. davigonz commented on Jan 26, 2018

    @davigonz
    Contributor

    I am using the BETA Android app.

    @DaanTry in this comment you reported the login redirection with 2.5.0, have you noticed the problem with 2.5.0 and after installing 2.5.1 beta 1 it appears again or you just wrote down the wrong app version? Thanks

  24. DaanTry commented on Jan 26, 2018

    @DaanTry
  25. PVince81 commented on Jan 26, 2018

    @PVince81

    @DaanTry given the data above, I expect that the problem will disappear for you if you switch back to 2.5.0.

  26. DaanTry commented on Jan 30, 2018

    @DaanTry
  27. davigonz commented on Jul 26, 2018

    @davigonz
    Contributor

    Hi @johnkj , have you noticed this problem again with the recent versions of the Android app, such as 2.8, released a couple of weeks ago?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions