Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Repeated "API Session Token expired" modal when attempting to view Passwords app #705

Open
6 tasks done
synthead opened this issue Feb 17, 2025 · 12 comments
Open
6 tasks done
Labels
bug Something in the app is not working as expected

Comments

@synthead
Copy link

synthead commented Feb 17, 2025

⚠️ This issue respects the following points: ⚠️

  • This is a single bug, not a question or a configuration/webserver/proxy issue.
  • This is not a bug in the browser extension or another client.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server and the Passwords App is up to date. See Nextcloud Apps.
  • There are no warnings and errors reported in the Passwords App settings in the admin area
  • The following apps are not installed: Rainloop

Server Information

{
    "version": {
        "server": "30.0.6.2",
        "app": "2024.12.21",
        "lsr": false,
        "php": "8.2.27",
        "cronPhp": "8.3.15"
    },
    "environment": {
        "os": "Linux",
        "architecture": "x86_64",
        "bits": 64,
        "database": "pgsql",
        "cron": "cron",
        "proxy": false,
        "sslProxy": false,
        "subdirectory": false
    },
    "services": {
        "images": "imagick",
        "favicons": "default",
        "previews": "default",
        "security": "hibp",
        "words": "auto",
        "previewApi": false,
        "faviconApi": false
    },
    "status": {
        "autoBackupRestored": false
    },
    "settings": {
        "channel": "stable",
        "nightlies": false,
        "handbook": false,
        "performance": 5
    },
    "encryption": {
        "sse": {
            "SSEv1r1": false,
            "SSEv1r2": true,
            "SSEv2r1": false,
            "SSEv3r1": false,
            "none": false,
            "default": "SSEv1r2"
        },
        "cse": {
            "CSEv1r1": false,
            "none": true,
            "default": "none"
        }
    }
}

Client Information

Browser and Version: Firefox 135.0
Client OS and Version: Arch Linux (rolling release, no version)

Bug description

After upgrading Nextcloud 30.0.5 to 30.0.6, I am not able to use the Passwords app. I am seeing this modal in the browser:

Image

When the "X" is clicked, the error is revealed under the model for a second before the browser refreshes:

Image

When the refresh occurs, the model in the first screenshot is displayed, and it continues in an interactive, infinite loop.

In the network inspector, I can observe that this reqest:

https://myserver/index.php/apps/passwords/api/1.0/session/request

...returns 401 with the body:

{"message":"CORS requires basic auth"}

In addition, in nextcloud.log, when loading the Passwords app, I am able to observe this entry:

{
  "reqId": "<censored>",
  "level": 0,
  "time": "2025-02-17T20:48:35+00:00",
  "remoteAddr": "10.1.0.1",
  "user": "--",
  "app": "core",
  "method": "GET",
  "url": "/index.php/apps/passwords/api/1.0/session/request",
  "message": "could not get login credentials because the token is invalid: Token does not exist: token does not exist",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0",
  "version": "30.0.6.2",
  "data": {
    "app": "core"
  }
}

I should mention that Nextcloud and the Passwords app has been working fine for years. This problem seems to have been triggered after the update to Nextcloud 30.0.6.

Steps to reproduce

There's probably something I'm missing, but I am reproducing this via:

  1. Install nextcloud 30.0.6-1 on Arch Linux.
  2. Install the Passwords app.
  3. Attempt to open the Passwords app.

Expected behavior

  1. Open the Passwords app.
  2. The Passwords app is displayed.

Nextcloud Logs

{
  "reqId": "<censored>",
  "level": 0,
  "time": "2025-02-17T20:48:35+00:00",
  "remoteAddr": "10.1.0.1",
  "user": "--",
  "app": "core",
  "method": "GET",
  "url": "/index.php/apps/passwords/api/1.0/session/request",
  "message": "could not get login credentials because the token is invalid: Token does not exist: token does not exist",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0",
  "version": "30.0.6.2",
  "data": {
    "app": "core"
  }
}

Browser Logs

n/a
@synthead synthead added the bug Something in the app is not working as expected label Feb 17, 2025
@marius-wieschollek
Copy link
Owner

I can currently not reproduce this at all. It reminds me of an issue we had earlier last year.

Can you ensure that there is no app related Javascript etc. cached anywhere in your browser or the server?

@adrienjacob
Copy link

I have the same issue since upgrade to 30.0.6 (30.0.5 was ok, wish I could downgrade)... It occurs on several browsers (firefox, chrome, opera), and also the Firefox plugin.

After googling the issue, I came accross this one, dunno if it's related : nextcloud/server#50619
It's also related to login and seems to affect several apps, but trying to appy the suggested fix didn't solve it for me.

@synthead
Copy link
Author

Thank you very much for your response, @marius-wieschollek! I don't have any cache getting in the way, and can reproduce this issue after clicking the "Clear cookies and site data..." option under the "lock" in the URL bar in Firefox.

@adrienjacob, wow, I'm very thankful that I'm not alone! I hope that we figure this one out. Being locked out of your passwords is not fun.

I should also add that I use the Passwords app here, and the app itself said something about credentials not being valid (I don't fully remember; it appeared and went away), then it also logged out client-side.

@synthead
Copy link
Author

I wonder if this is somehow related? nextcloud/server#50917

@synthead
Copy link
Author

synthead commented Feb 21, 2025

It appears that the only place the "CORS requires basic auth" error message comes from in beforeController here:

	/**
	 * This is being run in normal order before the controller is being
	 * called which allows several modifications and checks
	 *
	 * @param Controller $controller the controller that is being called
	 * @param string $methodName the name of the method that will be called on
	 *                           the controller
	 * @throws SecurityException
	 * @since 6.0.0
	 */
	public function beforeController($controller, $methodName) {
		$reflectionMethod = new ReflectionMethod($controller, $methodName);


		// ensure that @CORS annotated API routes are not used in conjunction
		// with session authentication since this enables CSRF attack vectors
		if ($this->hasAnnotationOrAttribute($reflectionMethod, 'CORS', CORS::class) &&
			(!$this->hasAnnotationOrAttribute($reflectionMethod, 'PublicPage', PublicPage::class) || $this->session->isLoggedIn())) {
			$user = array_key_exists('PHP_AUTH_USER', $this->request->server) ? $this->request->server['PHP_AUTH_USER'] : null;
			$pass = array_key_exists('PHP_AUTH_PW', $this->request->server) ? $this->request->server['PHP_AUTH_PW'] : null;


			// Allow to use the current session if a CSRF token is provided
			if ($this->request->passesCSRFCheck()) {
				return;
			}
			// Skip CORS check for requests with AppAPI auth.
			if ($this->session->getSession() instanceof ISession && $this->session->getSession()->get('app_api') === true) {
				return;
			}
			$this->session->logout();
			try {
				if ($user === null || $pass === null || !$this->session->logClientIn($user, $pass, $this->request, $this->throttler)) {
					throw new SecurityException('CORS requires basic auth', Http::STATUS_UNAUTHORIZED);
				}
			} catch (PasswordLoginForbiddenException $ex) {
				throw new SecurityException('Password login forbidden, use token instead', Http::STATUS_UNAUTHORIZED);
			}
		}
	}

What I find kind of weird is how CORS detection is being triggered. I'm running Passwords on my Nextcloud instance in the typical way, and there should not be any CORS requests being made.

@SkyBlueHH
Copy link

SkyBlueHH commented Feb 22, 2025

Unfortunately, I am also affected by this bug. However, I run several installations, but only have this error with one hoster on shared webspace: IONOS. Two independent installations are affected here. I have not yet been able to find out what is different with this hoster than with the others.

Debug information:
{ "version": { "server": "30.0.6.2", "app": "2024.12.21", "lsr": false, "php": "8.3.17", "cronPhp": "8.3.17" }, "environment": { "os": "Linux", "architecture": "x86_64", "bits": 64, "database": "mysql", "cron": "cron", "proxy": false, "sslProxy": false, "subdirectory": false }, "services": { "images": "gdlib", "favicons": "default", "previews": "default", "security": "hibp", "words": "auto", "previewApi": false, "faviconApi": false }, "status": { "autoBackupRestored": false }, "settings": { "channel": "stable", "nightlies": false, "handbook": false, "performance": 5 }, "encryption": { "sse": [], "cse": [] } }

Error log:
{ "reqId": "***", "level": 0, "time": "2025-02-20T11:10:40+00:00", "remoteAddr": "x.x.x.x", "user": "--", "app": "core", "method": "GET", "url": "/index.php/apps/passwords/api/1.0/session/request", "message": "could not get login credentials because the token is invalid: Token does not exist: token does not exist", "userAgent": "***", "version": "30.0.6.2", "data": { "app": "core" }, "id": "***" }

{ "reqId": "***", "level": 0, "time": "2025-02-20T11:10:40+00:00", "remoteAddr": "x.x.x.x", "user": "--", "app": "no app in context", "method": "GET", "url": "/index.php/apps/passwords/api/1.0/session/request", "message": "Logging out", "userAgent": "***", "version": "30.0.6.2", "data": { "user": "null" }, "id": "***" }

@adrienjacob
Copy link

Indeed, I happen to be on Ionos too... this may be the culprit.
I suspected issues with the cache as I'm on a shared hosting with limited possibilities in terms of config. Disabling it didn't solve anything.
It's indeed strange that it does not happen on other providers. Maybe a PHP or apache setting ?

@SkyBlueHH
Copy link

SkyBlueHH commented Feb 22, 2025

Interesting detail.

What I also tested:
A temporary change of the PHP version from 8.3 to 8.2: the bug remains.
Disable PHP OPcache: the bug remains.
Updated Database from MariaDB 10.5 to 10.11: the bug remains. (But that shouldn't matter anyway.)
PHP error log: no entries.

However, synthead's configuration does not look as if he is also an IONOS customer (as he uses PostgreSQL). Not to forget that the bug did not exist with 30.0.5, a strange behavior…

@synthead
Copy link
Author

@SkyBlueHH @adrienjacob, thank you for your sharing! I don't use IONOS; I run Nextcloud and the Passwords app on Arch Linux, host it with uWSGI, and proxy it with Nginx. I use PostgreSQL as the database. As mentioned before, I have been running the same deployment for years without issues, and a a recent upgrade seemed to trigger this bug.

I am curious how IONOS runs their hosted Nextcloud instances. This guide seems to hint that they favor Nginx and Nextcloud in Docker containers:

@synthead
Copy link
Author

Just sent this email to [email protected]!

Hi IONOS!

I am not a customer of IONOS, but I am writing on behalf of a couple IONOS customers who appear to have an identical bug with the Passwords app on Nextcloud!  Here is a link to the GitHub issue I filed:

#705

More context is in the issue, but just to summarize: after an upgrade to Nextcloud 30.0.6, the Passwords app shows the modal below.  After clicking the "X", the page is refreshed, and the modal appears again.  This seems to always occur, which prevents the Passwords app from loading.

Image

If you have the time, it would be great to have someone chime in on this GitHub issue!  This does appear to concern your customers, and hopefully the fix could help others, too :)

@synthead
Copy link
Author

I got this response:

Dear Customer,

Thank you for contacting IONOS Customer Service.,

As you are contacting us from an unidentified mailbox, we are unable to handle your support request. In order for us to support you, please contact us from the email address associated with your IONOS account.

Alternatively, you can converse with our online digital assistant within your Control Panel, which can provide immediate answers to many customer queries. You can access our online digital assistant, or find more contact information, within your IONOS account

If your concern is terminating a contract, you can call us or submit your termination directly through your IONOS account.

If you do not have an account with us, you can find our contact information on our website here

Sincerely,

IONOS

@SkyBlueHH
Copy link

Hi synthead, what did you expect when you wrote a support request as a non-customer? However, customer support is rarely very helpful there, especially as the error seems to be very specific.
Incidentally, the article on Docker only refers to cloud servers. There you would presumably also have complete configuration options. Unfortunately, we are only dealing with shared webspace – with limited options in configuration.
However, the fact that the bug also occurs with your installation shows that there must be a more fundamental problem. Nevertheless, I can try to contact customer support tomorrow, but I don't really expect any useful help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something in the app is not working as expected
Projects
None yet
Development

No branches or pull requests

5 participants
@synthead @marius-wieschollek @adrienjacob @SkyBlueHH and others