auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

We cannot trust `session.user` on the client side

Open j4crev opened this issue 2 years ago • 3 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Using data from session.user to render user information is just as insecure on the client side as it is on the server side.

This is because an attacker can signup for an account, login, then change the value of session.user.id in their own cookie, then make a request to the vulnerable app page.

To Reproduce

As with the server side vulnerability, this one also relies on an attacker knowing the Supabase user id of the targeted victim user.

  1. Login to an app
  2. Copy the value of your own auth token
  3. Remove the base64- prefix from the value
  4. Decode the value to get the session
  5. Replace session.user.id with the victim's user id.
  6. Base64 encode the tampered session and prefix it with base64-
  7. Copy the value back into your cookie.
  8. Go to a page that renders sensitive user data based on session.user.id. The victim user's data will be revealed.

Additional Context

https://github.com/orgs/supabase/discussions/23224

j4crev avatar Jul 29 '24 02:07 j4crev