php - Preventing erroneous AJAX Calls by the user -
i have webpage in user awarded x points on clicking button. button sends ajax request(jquery) php file awards points. uses post.
as client side, php file, parameters visible user.
can user automate process making form same fields , sending request ?
how can avoid type of csrf ? session authentication not useful.
you should handle on server-side, if want prevent multi-vote or prevent same people voting several time on same subject. why real votes use authenticated users , never anonymous votes.
by checking request xmlhttprequest (with @shaun hare response code or linked stackoverflow question in questions comments) block of csrf won't prevent repost user, using tools livehttpheaders 'replay' , such. everything coming client side can forged, everything.
edit* if it's not voting system commented, problem teh same, nedd 'something' know if user doing action first time, or if can still action. there's lot of different things available.
you can set token on page, use token in ajax requests, , invalidate token later usage server side. 1 way. problem store these tokens server-side (sessions, caches, etc)
another way check on server side situation still valid situation (for example request asking update 'something' should maybe handle hash/marker/timestamp can verify current server side state.
this generic question, solutions depends on reality of 'performed action'.
Comments
Post a Comment