--author:scott--date:20261013--for:【安全 GHSA-wv6f-p5mv-2g6f】重置密码短信验证码错误满5次作废,登录图形验证码一次一用

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
zhangdaiscott 2026-10-13 07:01:42 -04:00
parent e291cf00ff
commit 22666de2ce
2 changed files with 16 additions and 1 deletions

View File

@ -983,6 +983,9 @@ public class LoginController {
result.setCode(HttpStatus.PRECONDITION_FAILED.value());
return null;
}
//update-begin---author:scott ---date:20261013 for:【安全】图形验证码校验通过后立即作废(一次一用),防止同一验证码被反复用于尝试登录-----------
redisUtil.del(realKey);
//update-end---author:scott ---date:20261013 for:【安全】图形验证码校验通过后立即作废(一次一用),防止同一验证码被反复用于尝试登录-----------
return realKey;
}
}

View File

@ -1380,7 +1380,19 @@ public class SysUserController {
}
if(!smscode.equals(object.toString())) {
result.setMessage("短信验证码不匹配!");
//update-begin---author:scott ---date:20261013 for:【安全 GHSA-wv6f-p5mv-2g6f】验证码错误满5次即作废,防止暴力枚举验证码重置他人密码-----------
String errKey = redisKey + ":err";
long errCount = redisUtil.incr(errKey, 1);
if (errCount == 1) {
redisUtil.expire(errKey, 600);
}
if (errCount >= 5) {
redisUtil.del(redisKey, errKey);
result.setMessage("短信验证码错误次数过多,请重新获取!");
} else {
result.setMessage("短信验证码不匹配!");
}
//update-end---author:scott ---date:20261013 for:【安全 GHSA-wv6f-p5mv-2g6f】验证码错误满5次即作废,防止暴力枚举验证码重置他人密码-----------
result.setSuccess(false);
return result;
}