@@ -416,6 +416,29 @@ private function logLoginDiag(string $what, string $user): void {
416416 } catch (\Throwable ) {
417417 $ sessCookie = 'err ' ;
418418 }
419+ // Hash of the raw CSRF token value STORED in this session, and of the
420+ // value the client PROVIDED. If the /login session is the same one
421+ // /csrftoken issued into, storedTok here must equal the storedTok that
422+ // CSRFTOKEN logged. A mismatch proves the two requests hit different
423+ // sessions (or the token rotated) — the real csrfCheckFailed cause.
424+ $ storedTok = 'n/a ' ;
425+ try {
426+ $ t = $ this ->session ->get ('requesttoken ' );
427+ if (is_string ($ t ) && $ t !== '' ) {
428+ $ storedTok = substr (md5 ($ t ), 0 , 8 );
429+ }
430+ } catch (\Throwable ) {
431+ $ storedTok = 'err ' ;
432+ }
433+ $ providedTok = 'none ' ;
434+ try {
435+ $ p = $ this ->request ->getParam ('requesttoken ' );
436+ if (is_string ($ p ) && $ p !== '' ) {
437+ $ providedTok = substr (md5 ($ p ), 0 , 8 );
438+ }
439+ } catch (\Throwable ) {
440+ $ providedTok = 'err ' ;
441+ }
419442 \OCP \Server::get (\Psr \Log \LoggerInterface::class)->error (
420443 '[login-diag] ' . $ what
421444 . ' user= ' . $ user
@@ -424,6 +447,8 @@ private function logLoginDiag(string $what, string $user): void {
424447 . ' sessCookie= ' . $ sessCookie
425448 . ' strictCookie= ' . $ strictCookie
426449 . ' sessHasReqToken= ' . $ sessHasReqToken
450+ . ' storedTok= ' . $ storedTok
451+ . ' providedTok= ' . $ providedTok
427452 . ' csrf= ' . ($ this ->request ->passesCSRFCheck () ? '1 ' : '0 ' )
428453 . ' origin= ' . $ this ->request ->getHeader ('Origin ' )
429454 . ' delay= ' . $ this ->throttler ->getDelay ($ remote , 'login ' ),
0 commit comments