Lets say there is AJAX application where user can submit items - buy them.

And there was a code

IF ($_POST[items] > 20) {
   echo 'error';
else {
   echo 'success'

So there is a check if items is not more than 20, lets say on client side it is not possible to choose more than 20 items, but atacker can edit the javascript and chooose.

But system would work without problems even if 21 or any other amount would be submited. Usually - every scream that you dont trust client side. And I agree.

But in this case I think its enough to trust client, because nothing bad will happen if he submits more than this amount of items. When submiting more - he will have to pay more, so thats kind of automatic protection.

Ok, maybe system would crash if there was 15000 items submited. That is maybe better reason for protection. Still if minimum amount for item is 1$, he will have to have in his account 15000 $ to really buy those items.

And in worst case might be set some script run time out, so if errors are disable, he will just not get back any response if script times out.

I am not only talking about this situation, but in general. Does it make sense to write protections from something which you dont see how system can be hacked. And if someone says to protect - shouldn't they explain the reason why this place should have check? Not like the answer - "its always better to check, you dont know where hacker could hack you". But first find real example how the hacker will hack you.

Or lets take real world example - there is a house, which have 1 door, 5 windows, walls. We understand that thief first would go through doors if they dont have a lock. So we protect hours with the lock.

If we need more protection, second thing where thief might go is windows, so we can add something for windows to protect.

But we would not think that thief would to through walls, assuming they are from bricks. It is possible also, but then its also possible that your php server will be physically bombed and you need to have some military machines to protect your server :D



Browse other questions tagged .