-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Unwanted authData validation #3867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This should have been addressed by this: #3783 |
I've been aware of this issue for a while, and I expected #3783 to fix it, which is why I made the update and re-tested. As far as I know this hasn't solved the issue. From what I understand from your commit, you've juste moved the issue, because the |
Yeah, but the validation should only be executed if the authData has changed, providing the same auth token as the one that created the user (or the last valid update). I can add an additional test with your PUT request to try to reproduce your STR. In the meantime, could you provide the server logs please? (User creation/link with Facebook as well as the failing PUT call?) |
Here is the request:
As far as I understand, the code that checks whether the authData are identical is never executed. Here is the stack trace that I have after some quick printing:
|
Just tried without the twitter auth just in case, same problem. Just put a print in So the reason the test is not executed is probably the I've never looked at Parse Server code before, so I might be wrong... |
Right I get it now. The skip is on login only and not in the case of the PUT. Are you willing to provide a fix for it? That should not be too hard |
Well I would definitely like to contribute, but I don't think I can... I'm not a Javascript developer. I can read and understand the general idea, but I don't think I can fix it. |
You actually managed to find the problem :) with a few trial an error, I'm sure you can manage it :) worst case, I can do it in the next days, but that's a good opportunity to learn ;) |
I still don't understand how you differentiate the login from the PUT request. Is this just the Let's say you have 2 devices connected with the same Facebook account, each with a different token (but the same Facebook id). One of the device will not have the right token and it will generate a token check on every update. If the token of this device expires, then the device is locked out until a new token is obtained. Shouldn't the process of comparing 2 authData be moved to the auth adapter ? The In I've only looked at Parse Server code today, so I'm going to pass on pull requests for now, but I'll probably work more with Parse Server in the following weeks or months, so when I understand better how it works I'll consider fixing some bugs. What would really help though is an explanation of how all the components work together. There is documentation in the code that explain what each method does, but nothing that gives you the big picture. |
That would imply having that logic in all auth adapters, making some more vulnerable than others. In general, the token should be valid when updated to the database. With the latest fix, this should cover that properly. Starting now, and on iOS, if you send a valid auth token, this will update the DB. If you send an invalid auth token and that token is still the same as the previous one, the request will not fail. |
Thanks a lot for the fix! There are still some corner cases that will not work, but as you say, this will cover the main case where the token sent is the same as the one in database. I have a question though: What happens if you try to login with stale authData (invalid token, but same as the one in the database)? I would expect the login to fail in this case for security reasons (I haven't tested, but I'll try to when I get the time). |
This should be supported, and was actually the 1st supported case. |
Yes, I just tested. I'm actually saying it shouldn't work.
Where
Then it will always succeed if you pass the same authData as the one in database, even if the token has been revoked because the token is not validated. I think you should differentiate two scenarios :
But we can leave it as is it. To be honest, your fix on the update call was important to me because it avoids locking out users. This on the other hand is much less important. The odds of someone getting their hands on the token event if it's revoked are pretty slim anyway. |
Just saw on your original pull request (#3783) that this was by design. Don't really understand why though. |
That was probably overlooked at the 1st PR, with the intended behaviour on PUT and not on login. |
Issue Description
Parse Server is validating authData whenever the user object is updated. In many cases, this is unwanted and makes a perfectly good request fail.
I only tested this with Facebook, but since the handling of authData seems to be build in a rather generic way, I expect this issue to arise with other auth providers as well.
Steps to reproduce
Expected Results
As long as I have a valid session, I expect to be allowed to modify custom fields on my user object, regardless of the validity of the authData.
I understand that the main issue here is the fact that the iOS SDK includes the authData in all PUT requests, even if it hasn't changed. I also understand that even with a valid session you can't be allowed to put anything in authData because it would allow you to put the id of a Facebook account you don't own.
Actual Outcome
A very real world outcome is the following:
Possible fix
If the authData sent in the request is identical to the authData saved in the database, don't perform any validation. You could even go as far as only checking that the id fields of authData are identical and allow any arbitrary change to the token or expiring date without further validation.
Environment Setup
Parse Server version 2.4.1 running locally or on Heroku (tried both)
Node 6.10
MongoDB storage on Mlab.
Tried on iOS only
The text was updated successfully, but these errors were encountered: