views:

249

answers:

5

How can I prevent that forms can be scanned with a sort of massive vulnerability scanners like XSSME, SQLinjectMe (those two are free Firefox add-ons), Accunetix Web Scanner and others?

These "web vulnerability scanners" work catching a copy of a form with all its fields and sending thousands of tests in minutes, introducing all kind of malicious strings in the fields.

Even if you sanitize very well your input, there is a speed response delay in the server, and sometimes if the form sends e-mail, you vill receive thousands of emails in the receiver mailbox. I know that one way to reduce this problem is the use of a CAPTCHA component, but sometimes this kind of component is too much for some types of forms and delays the user response (as an example a login/password form).

Any suggestion?

Thanks in advance and sorry for my English!

+1  A: 

Theres only so much you can do... "Where theres a will theres a way", anything that you want the user to do can be automated and abused. You need to find a median when developing, and toss in a few things that may make it harder for abuse.

One thing you can do is sign the form with a hash, for example if the form is there for sending a message to another user you can do this:

hash = md5(userid + action + salt)

then when you actually process the response you would do

if (hash == md5(userid + action + salt))

This prevents the abuser from injecting 1000's of user id's and easily spamming your system. Its just another loop for the attacker to jump through.

Id love to hear other peoples techniques. CAPTCHA's should be used on entry points like registration. And the method above should be used on actions to specific things (messaging, voting, ...).

also you could create a flagging system, and anything the user does X times in X amount of time that may look fishy would flag the user, and make them do a CAPTCHA (once they enter it they are no longer flagged).

Chad Scira
Good idea, but not sure it will help backlash17 because he sort of implied he does not have "users".
Tom
well if he doesnt have users... then the only way i can see of him actually securing his site would require users to authenticate their sessions and implement a flagging system on top of the session. So if a new user comes to the page they have to enter a CAPTCHA on the first action, if they passed it they are verified. If the user does something that looks like abuse they get flagged and have to pass another CAPTCHA.
Chad Scira
+4  A: 

Hmm, if this is a major problem you could add a server-side submission-rate limiter. When someone submits a form, store some information in a database about their IP address and what time they submitted the form. Then whenever someone submits the form, check the database to see if it's been "long enough" since the last time that IP address submitted the form. Even a fairly short wait like 10 seconds would seriously slow down this sort of automated probing. This database could be automatically cleared out every day/hour/whatever, you don't need to keep the data around for long.

Of course someone with access to a botnet could avoid this limiter, but if your site is under attack by a large botnet you probably have larger problems than this.

Chad Birch
someone that would be doing this kind of attack would most likely be using a botnet
Chad Scira
Yes, a botnet using a Firefox addon. Somehow I doubt it.
Chad Birch
+1  A: 

On top the rate-limiting solutions that others have offered, you may also want to implement some logging or auditing on sensitive pages and forms to make sure that your rate limiting actually works. It could be something simple like just logging request counts per IP. Then you can send yourself an hourly or daily digest to keep an eye on things without having to repeatedly check your site.

Rob Hruska
+1  A: 

This question is not exactly like the other questions about captchas but I think reading them if you haven't already would be worthwhile. "Honey Pot Captcha" sounds like it might work for you.

rlb.usa
Honey pot CAPTCHA is basically an invisible field that human users can't see, but vulnerability scanners do. It is a good aproach. I'll think about it. Thanks.
backslash17
A: 

Reviewing all the answers I had made one solution customized for my case with a little bit of each one:

I checked again the behavior of the known vulnerability scanners. They load the page one time and with the information gathered they start to submit it changing the content of the fields with malicious scripts in order to verify certain types of vulnerabilities.

But: What if we sign the form? How? Creating a hidden field with a random content stored in the Session object. If the value is submitted more than n times we just create it again. We only have to check if it matches, and if it don't just take the actions we want.

But we can do it even better: Why instead to change the value of the field, we change the name of the field randomly? Yes changing the name of the field randomly and storing it in the session object is maybe a more tricky solution, because the form is always different, and the vulnerability scanners just load it once. If we don’t get input for a field with the stored name, simply we don't process the form.

I think this can save a lot of CPU cycles. I was doing some test with the vulnerability scanners mentioned in the question and it works perfectly!

Well, thanks a lot to all of you, as a said before this solution was made with a little bit of each answer.

backslash17