grep
grep

Reputation: 4026

AJAX security questions

I was hoping to clear up some questions I have been having with AJAX security. So here is a scenario I am trying to wrap my head around.

Lets say I am using AJAX to request some semi-sensitive material to the page. For instance, I am going to pass the user's ID to a php file, and return some information about themselves. Now, what is keeping someone from emulating this Javascript request, and passing different ID's to the PHP script?

Upvotes: 4

Views: 269

Answers (2)

Marc B
Marc B

Reputation: 360812

AJAX is inherently un-securable. You cannot both make a resource available for remote usage AND keep it completely secure. There is no 100% reliable method for identifying if a request came in from your client-side javascript or if it's someone faking the request.

At most, you can make it harder/more tedious to do such faking.

Upvotes: 2

tskuzzy
tskuzzy

Reputation: 36476

An Ajax call is exactly identical to any other HTTP request that you make except that it's asynchronous (it doesn't reload the web browser). So you should be using whatever authentication you currently employ on your web site.

This could either be Windows integrated security, cookies, etc. Basically your PHP script just has to verify that the request is coming from a valid user of your application.

Upvotes: 10

Related Questions