-
Notifications
You must be signed in to change notification settings - Fork 340
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
Security Flaw with localStorage #112
Comments
Yeah that's true, but ...
and then in the inspector you run these commands
This will show you the admin view but of course no info will show in the screen as all of it is stored in the database and the if in the route you added 'isAdmin' function
and in 'isAdmin' the verification is being done using the user's token
So he won't get anything that you marked as require Admin in the API Can you please share the modifications you did to your code to fix this? |
Yeah I think I even mentioned to the team it wasn't that damaging as I suspected they really couldn't get any info so you are correct, the admin views are back end validated at some point. Here's the commits: vthacks-org@060a462 I made a quick change to the Session.js to remove any reference to current user:
and then on the routes.js checked if they had a token and if they did then checked the user against the api:
but this is a kind of janky hot fix I put in place while I looked into it. It does seem to work, though. I bet there's a better fix that might be a little more far reaching. The session should probably be tracked with a cookie instead of via localStorage but that might take a bit more work, if we end up going that route I will happily change it and submit it. |
TLDR hiding an interface from users of a client-side app requires never delivering the interface, but deliving the admin interface probably isn't harmful Currently, hiding the admin interface (just the UI, not admin facing content such as user info) from users is not a feature in Quill. All Angular templates are accessible by the client, regardless of admin status. To get around the proposed fix, just add a breakpoint after the API call or intercept the request itself. If hiding the admin templates/frontend logic is super important, I'd recommend building a separate angular app that does authentication before delivery. This is only necessary if the admin interface contains features you don't want users to be aware of. |
I think intercepting the request might be a good idea. I know, just in general, storing volatile things in local storage is not usually recommended (e.g. user data). Like we have said, they can't actually harm anything or do any damage so there is no actual security flaw. In general, they shouldn't be able to access admin though and I think my fix does a good job at just not allowing that the way this person tried it. You can close this issue if the existing behavior is fine and since its not dangerous and as you said, angular templates are all accessible by the client. |
There is a major security issue with how the user data is stored and accessed.
First off, in Session.js when a new Session object is created the user is stored in local storage
This seems fine as they are themselves, however, in routes.js
We get from Session.getUser which just fetches the user from localStorage. So, if a user just opens the inspector and changes the localStorage object:
they can gain access to the admin tab
We actually had an attendee of our hackathon note this to us and we are mostly admins already so we didn't recreate exactly before changing this. Either way, I made a change that makes Session.getUser use the existing
users/:id
route in the api and I still store the user id in local storage, as that seems relatively harmlessThe text was updated successfully, but these errors were encountered: