← PHP / Laravel · 目录

PHP-025 / 中级

未限制登录尝试频率(Rate Limit)

A07:2021 Identification and Authentication Failures · CWE-307 Improper Restriction of Excessive Authentication Attempts

为什么存在问题?

可实施自动化穷举攻击,包括撞库攻击。

如何修复

php
Route::post('/login', [AuthController::class, 'login'])->middleware('throttle:5,1');
// 或通过 RateLimiter::for 限制 IP 与邮箱组合,累计失败后锁定

延伸阅读