Is there any technique that facebook can recommend (such as signing the uid and sending the signature along with the id on all server requests) so that the website isn't fooled?
Is there any technique that facebook can recommend (such as signing the uid and sending the signature along with the id on all server requests) so that the website isn't fooled?
If you mean: I have an authentication service, Auth.com, and I would like the users to be able to enter their user name and password on AnotherSite.com, how do I stop javascript on AnotherSite.com hijacking their submission to Auth.com?
Then the short answer is, you can't. That is why all services redirect you to their own login page, where they control the HTML (and can audit to be sure that no one has injected code into their site).
What Facebook does is usually in an iFrame, which accesses the user information relatively securely. Any interaction more complex than a "like" is generally redirected via facebook.com (e.g. any permission grants). iFrame's used to be riddled with flaws, but I believe they are considered fairly safe these days.
Go educate yourself on the protection of XSS and CSRF/XSRF, and you'll be able to answer all of your own questions.
I am asking another question.
If I am operating an OpenID provider, say Auth.com, and CoolStuff.com uses me to authenticate a user, then they can use that session. Great. But now let's say I operate an OAuth provider, and it releases this user's uid, first_name and last_name. What measures does facebook and other OAuth providers take to prevent the uid, first_name, last_name and other data from just being changed by the user in javascript, before being posted to the CoolStuff.com servers, after they have been obtained using Javascript ... such as FB.api('fql.query', ...)
From my understanding of OAuth, when the uid, first_name and last_name are sent by auth.com it also sends a cryptographic hash of everything. So if you change the uid, you would also have to change the hash and you can't change the hash without knowing the shared secret that the auth.com and coolstuff.com have decided on prior to your request.
I'm intrigued now, I hope someone can give details!
For example, with Facebook, once a user has logged in and given Application X permission to access their details, FB will send the user's id, name, etc. (whatever data the user has granted access to) along with a unique access token. The next time, and every subsequent time Application X wants to access the FB API on the user's behalf it is required to send that access token. From javascript you might be able to change the token, however, Application X's next interaction with the FB API will fail if the token is invalid and there is no way to derive a token value from a FB user's id.
I don't have to change the token. I just have to change the data given by facebook (including the uid) before the website's dumb javascript uses it in a post back to the server. Since it's not signed by Facebook, how can the website's server trust the uid? Never trust your user input.
Facebook returns a uid. When the user takes an action, this uid is sent to the server. The server trusts the uid, and saves this action as taken by the user identified by this uid.
And let's say it's not the uid. Let's say it's the user's name.
It trusts the user input basically. But it should probably be getting it directly from facebook, or in a signed structure, right?