phpbb icon indicating copy to clipboard operation
phpbb copied to clipboard

Improve handling of DDoS/brute force attacks on login form

Open rob006 opened this issue 3 years ago • 1 comments

Checklist:

  • [x] Correct branch: master for new features; 3.3.x for fixes
  • [ ] Tests pass
  • [ ] Code follows coding guidelines: master and 3.3.x
  • [ ] Commit follows commit message format

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 of session_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).

rob006 avatar Apr 12 '22 22:04 rob006

Plese open a ticket in the tracker, first. Then link it to your PR which should follow the guidelines, thanks..

3D-I avatar Apr 14 '22 05:04 3D-I