← PHP / Laravel · Contents

PHP-054 / Advanced

Trusting two-factor authentication status solely through the session

A07:2021 Identification and Authentication Failures · CWE-304 Missing Critical Step in Authentication

Why is this a problem?

Skipping the OTP step and accessing /dashboard directly bypasses 2FA.

How to fix it

php
session(['2fa:pending' => $user->id]);      // Auth::login and regenerate() only after OTP succeeds

Further reading