http://www.perlmonks.org?node_id=262488


in reply to Re: Re: Re: hash collision DOS
in thread hash collision DOS

The problem is that the attacker is generating the strings that go into the hash table. He chooses strings that collide and produce the worst-case performance. The worst-case performance isn't likely in normal use, but is easy for a malicious attacker to construct the strings.

There are some limits on how many strings can be inserted by an attacker. CGI.pm limits POST sizes. With a 1 MB limit and 10 bytes per string, that is 100,000 strings all trying to go into one hash bucket. Instead of taking a fraction of a second to parse, it takes the web server thousands of seconds.

It would be possible to add checks to prevent this attack. One easy way is limit the number of parameters in CGI.pm. 1000 is probably a reasonable limit. The proper solution is change the Perl hashing function so it isn't deterministic. If the attacker can't predict the behavior, they can't the worst-case strings.