Skip to main content
Menu
Advisories

Two-factor challenge can be skipped for content gated with authenticated() or [authenticated]

GHSA-636M-8598-45R9Published Updated GitHub

Description

On a Grav site with two-factor authentication enabled, someone who knows a member's password but does not have that member's authenticator app can read content that page authors hid behind the Login plugin's authenticated() Twig function or its [authenticated] shortcode.

Details

With 2FA switched on, signing in happens in two steps: the password is accepted first, and the site then pauses to ask for the six-digit code. During that pause the session is marked as having passed the password step but not as having completed the login.

Login::isAuthenticated() — the code behind authenticated(), [authenticated] and [guest] — only read the first of those two flags, so a session sitting on the code prompt was treated as fully logged in for the purpose of showing member-only content.

The plugin's own page-access check has required both flags since v3.2.0, and the authenticated('some.permission') form of the helper was never affected, because it goes through Grav's UserObject::authorize(), which does check for a completed login. Only the no-argument form, authenticated(), and the group form, authenticated(null, 'editors'), were wrong.

The inverse [guest] shortcode was affected in the other direction: guest-only content disappeared as soon as the password was accepted, before the login was finished.

Impact

An attacker who has obtained a member's password — through reuse, phishing or cracking — but who cannot answer that member's second factor could read page content gated with authenticated() or [authenticated]. For that content, the second factor provided no protection.

The impact is limited to disclosure of that content. The attacker does not obtain a completed session, cannot reach pages protected by an access: rule, and cannot act as the user. Pages using access: rules, and the authenticated('permission') form of the helper, were never affected.

Sites are affected only if they have two-factor authentication enabled and use authenticated() or [authenticated] to gate content. Sites that do not use those are unaffected.

Affected versions

grav-plugin-login >= 3.8.7, < 3.9.7. The helper and the shortcodes were introduced in 3.8.7.

Patches

Fixed in grav-plugin-login 3.9.7. isAuthenticated() now requires a completed login before any of its checks pass, matching the test the plugin's page-access guard already used.

Workarounds

Until you can update, use a page-level access: rule instead of [authenticated], which was never affected.

Credits

Reported independently by @geoffrey-diederichs and @AlpetGexha. @geoffrey-diederichs supplied a complete, runnable proof of concept that also verified the fix.

Affected versions

References

GitHub · getgrav/grav