Nice thoughts - but isn’t this rather a problem that should be fixed on PHP level? I mean, isn’t any PHP app that uses sessions exposed to this problem?
1/ Secure cookies wouldn’t help because (as far as I understood) a central precondition of the described DoS is, that the client does not accept cookies.
2/ A malicous client would simply not include the session id in the GET request.
(Besides: How would you differentiate between an empty and an expired Session?)
3/ The Framework is the wrong place to mitigate this problem.
@mike: AFAIK not just PHP, but every web scripting language. If you want to persist state, it must be stored somewhere. Even if it is memory.
Instead of pointing your script to a simple index-page, you could also point the script to a page which consumes much cpu or executes many db-queries. This would bring a site down faster than creating dummy sessions.
Protection against such DoS-attempts should be dealt with at system/webserver level - or in best case with a hardware based solution. Such "evil" connections should never reach the php-parser if possible.
If there’s no knowledge or money for a good protection, then one could simply make a little PHP snippet that protects against http-based DoS attacks (eg exit() if ip connected more than X times within X seconds).
The client not passing the session id in the GET request is not a problem. To differentiate between empty and expired session requires encoding a timestamp in the session id.
This could work but seems a lot of useless work because the solution is simple: Don’t create session unless you have to.
And: If your server can’t handle 1.000.000 requests I assume dummy sessions are the least thing to worry about. Think about memory consumption, or as mentioned, expansive db queries.
A PHP script the keeps track of the number of connections per IP is, of course, not a substitution for protection at the lower level. Because you would have to store the number of connections per IP somewhere…
maybe setting autoStart=false would solve much of it
although I would prefer a different approach
> 1/ Secure cookies wouldn’t help because (as far as I understood) a central precondition of the described DoS is, that the client does not accept cookies.
in my proposal
we don’t allocate the session, we just create a secure cookie in other words nothing allocated server side
> 2/ A malicous client would simply not include the session id in the GET request.
then he will cost us a call to uniqid() to generate him a cookie, no resources would be consumed
> Besides: How would you differentiate between an empty and an expired Session?