icingaweb2/application/controllers
Johannes Rauh ba2b9e8282 Avoid storing full remember-me cookie in session during 2FA challenge
Previously the `RememberMe` object (containing the AES-encrypted password and
the decryption key) was serialized directly into the PHP session while waiting
for the user to complete the 2FA challenge. Because PHP sessions are written
to disk in plaintext, this exposed the key and ciphertext in the same place,
sufficient to recover the user's password.

Fix by splitting the secret across the session and the database, mirroring the
design of the normal (non-2FA) remember-me flow:

- Call `persist()` at login time so the AES key goes to the database
  immediately, never touching the session.
- Store only the cookie value string (ciphertext + IV) in the session.
  The ciphertext is not exploitable without the key.
- After a successful 2FA challenge, reconstruct the `RememberMe` object via a
  new `RememberMe::fromCookieData()` factory that does a DB lookup by IV and
  restores the canonical expiry from the database row.
- Only then send the browser cookie, so the cookie never reaches the browser
  unless the second factor was verified.

Canceled challenges remove the created DB row, while abandoned challenges
leave an orphaned DB row which is cleaned up by the existing
`RememberMe::removeExpired()` mechanism.

`RememberMe::fromCookieData()` sets `$expiresAt` from the database row so
the browser cookie issued after 2FA inherits the expiry stored at login time
rather than receiving a fresh 30-day window computed at challenge-completion
time. The renewal path in `AuthenticationController::loginAction()` is
unaffected, because `renew()` constructs a new object via `fromCredentials()`.
2026-05-20 09:40:14 +02:00
..
AboutController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
AccountController.php Add enrollment UI and two-factor tab to account navigation 2026-05-20 09:39:10 +02:00
AnnouncementsController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
ApplicationStateController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
AuthenticationController.php Avoid storing full remember-me cookie in session during 2FA challenge 2026-05-20 09:40:14 +02:00
ConfigController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
DashboardController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
ErrorController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
GroupController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
HealthController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
IframeController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
IndexController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
LayoutController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
ListController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
ManageUserDevicesController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
MigrationsController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
MyDevicesController.php Add enrollment UI and two-factor tab to account navigation 2026-05-20 09:39:10 +02:00
NavigationController.php Add enrollment UI and two-factor tab to account navigation 2026-05-20 09:39:10 +02:00
RoleController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
SearchController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
StaticController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
TwoFactorController.php Add enrollment UI and two-factor tab to account navigation 2026-05-20 09:39:10 +02:00
UserController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00
UsergroupbackendController.php License source files as GPL-3.0-or-later 2026-03-26 17:49:26 +01:00