Skip to content

[Bug]: Disabled AppAPI Extension Leads to MFA Login Loop #59233

@rtfmkiesel

Description

@rtfmkiesel

⚠️ This issue respects the following points: ⚠️

Bug description

When my colleagues and I are trying to log into our Nextcloud instance, we cannot do so without clearing our browser cache. If we did not clear our cache before accessing the site, we would land in an endless loop. The issue only happens with Firefox-based browsers (and not even all of them). It was tested with all browser extensions disabled, just in case.

Behavior/To reproduce

  1. Have a valid session the last time the browser was open. (yesterday, before lunch, ...)
  2. Open the browser, go to the base URL, get redirected to /login
  3. Enter credentials -> the POST /login request results in a redirect to /login/selectchallenge since we enforce MFA
  4. Select an MFA method (We use TOTP and WebAuthn, the issue happens with both)
  5. This results in the browser making a GET /login/challenge/totp request (in the case of TOTP) -> The server responds with a redirect to /login?redirect_url=/login/challenge/totp and we are back on the login page ¯_(ツ)_/¯

If we repeat this, the response from the server will always append the redirect_url parameter. So after the 2nd cycle, we end up on /login?redirect_url=/login/challenge/totp?redirect_url%3D/login/challenge/totp.

After some debugging, I landed in lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php due to the debug log printing:

"File":"/var/www/html/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php","Line":134,"message":"Current user is not logged in","exception":{},"CustomMessage":"Current user is not logged in"

In there, we get a NotLoggedInException because $authorized is false. Somehow, we fail the condition.

if ($this->userSession instanceof Session && $this->userSession->getSession()->get('app_api') === true && $this->userSession->getUser() === null) {
	$authorized = true;
}

Because I saw that app_api is somehow involved in this, I re-enabled the AppApi extension... and voila! It works again.

Do not ask me why this only happens with Firefox and not Chrome. Maybe a local cache issue since Nextcloud tries to re-establish a session with previous cookies/session data?

Steps to reproduce

See above

Expected behavior

A normal login flow (get prompted for MFA instead of a redirect to /login)

Nextcloud Server version

32

Operating system

Debian/Ubuntu

PHP engine version

None

Web server

None

Database engine version

None

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

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

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

Configuration report

List of activated Apps

Nextcloud Signing status

Nextcloud Logs

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap32-feedbackbug

    Type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions