Improve handling of DDoS/brute force attacks on login form #6383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist:
Tracker ticket (set the ticket ID to your ticket ID):
https://tracker.phpbb.com/browse/PHPBB3-
Background:
I had a DDoS attack on login form. It quickly filled the sessions table with tens of thousands of sessions for the anonymous user. A lot of sessions for this user dramatically decreased the performance of
SELECT COUNT(session_id) AS sessions FROM SESSIONS_TABLE ...
query, since the efficiency ofsession_user_id
index was almost non-existent (99% of sessions was for anonymous user, so the query needed to count almost all rows in table). I excluded this query for the anonymous user, since it was not needed anyway. This significantly improved performance of forum, but......sessions were still created and the sessions table was growing. I ignored this, but after a few days I realized that cron does not work correctly. It turns out that task for clearing old sessions tried to load hundreds of thousands of sessions in one query, which exceeded the memory limit, and the whole process failed (and this was repeated over and over since old sessions were never removed). I added a limit to this query, so sessions could be cleaned up in smaller batches (I'm still not sure if this limit is optimal, but it worked for me).