How should the strength and error lock of the password recovery verification code be configured?
The password recovery verification code, login verification code, and public form verification code, although they look like the same control, what they actually prevent is not the same thing.The number of digits and the random source determine whether it can be guessed, the validity period determines how long it can be used after being intercepted, and the error lock determines whether it can be tried repeatedly.The three items need to be configured together, any of which can be bypassed.
The three types of verification scenarios are not the same thing.
| Scene | Main risk | Strength orientation | Locking and timeliness |
|---|---|---|---|
| Password recovery | Bill guessed or reused | Reliable random source, the number of digits cannot be too small | Short validity period, expires after single use |
| Log in | Batch brute force | Failed count is more critical than the number of digits | Lock error count by binding to the same entry |
| Public form | Machine batch submission | Interactive verification is more suitable | Should not rely solely on captcha, should be combined with frequency limit |
The key to password recovery and the like is 'one-time': the verification code should be immediately invalidated after verification is passed to prevent the same code from being submitted repeatedly. The update log of PbootCMS in V3.2.25 (build 2026-09-08) strengthened the password recovery verification code, changing it to a 6-digit secure random generation, and adding expiration time and error count lock, consistent with the above three directions.
Why is the number of digits and random source important
When the number of digits is insufficient,配合无限次尝试,the cost of brute force can be low to the point of neglect. Therefore, 'increasing the number of digits' and 'limiting the number of attempts' are paired, and doing only one of them has limited benefits.
What is often ignored is the random source. Codes拼出的码,even if the number of digits is up to standard, may still hit within a limited number of attempts. Secure random generation solves this level: not dependent on timestamps, not dependent on sequential numbers.
The same type of issue is also recorded in the in-station repair records: v3.6.6 has handled the vulnerability of login credentials being forged in the site switching scenario, the approach is to change to a one-time ticket, and it is recommended to rotate the signature key and change the administrator's password. The common point of this change is -Turn the 'reusable credentials' into 'disposable credentials'.
How to match the validity period and error count lock
The validity period is determined according to the business process: in the scenario of password recovery, users usually complete the filling within a few minutes, and there is no need to leave a long expiration time; the cost of leaving a long time is to give the other party more opportunity to try.
Error count lock must be bound to the same entry. Prevent different approaches: locking the account alone cannot stop someone from trying the same email with a different account, and locking the source address alone cannot stop IP changes. When configuring, make sure the lock count and unlock conditions are written together, and do not appear locked without automatic release.
Robot protection and content protection division
This step in preventing form robots, the site supports integrating reCAPTCHA and similar verification codes in forms, transferring the judgment to interactive verification instead of manually drawing graphic codes. Its value lies in resisting batch submissions, but it is not the whole of content security: even if the submission action is legitimate, the content itself may still pose a risk.
In the content security settings of Anqi CMS, sensitive word filtering and keyword replacement, and content review handle the expression risk of submitted content, while JWT authentication and defense against SQL injection and XSS handle the risks at the interface and page layer. The three-tier division of labor is:reCAPTCHA blocks bots, sensitive word filtering manages expression, authentication and injection protection manages the channel. Entries such as comments and messages should be checked in three layers together; leaving only one open will leave a clear bypass path.
Self-check list
- Is the password recovery verification code a secure random generation, does it have an expiration time, and is it invalidated after verification?
- Is the error count lock bound to a specific entry, and is there an unlock path?
- Is the public form connected to interactive verification, and is it opened simultaneously with frequency limits?
- Is the comment content filtered and reviewed by sensitive words, rather than just looking at the submission frequency?
- Version upgrade instructions mention the need to rotate the key and modify the administrator's password, did it really execute?
Common questions
Question: If the number of digits is a bit more, do you have to do error locking?Answer: No. Increasing the number of digits increases the difficulty of guessing in one attempt, limiting the number of attempts to lock, and the product of both is the actual strength.
Question: The form has been flooded with spam, should you add a captcha first or add frequency restriction first?Answer: First, see if the submission is from batch requests from the same entry. If it's batch, then apply interactive verification and frequency restriction first; if the content is problematic, then add sensitive word filtering and review.
Question: Should the login of the background own open captcha?Answer: It is recommended to open based on risk. When the background entry is exposed to the public network, the failure count and lock ratio are more important than the front desk.