Skip to content
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

Impossible to determine if the record was really deleted #353

Closed
n-sviridenko opened this issue Oct 17, 2022 · 2 comments
Closed

Impossible to determine if the record was really deleted #353

n-sviridenko opened this issue Oct 17, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@n-sviridenko
Copy link

Bug report

Describe the bug

When RLS is enabled, if deletion is not allowed, it'll still return 200.

To Reproduce

  1. Create a table
  2. Enable RLS
  3. No policies needed, as deletion will be already not allowed
  4. Create a record in that table
  5. Do a DELETE request to delete a record from there

Expected behavior

A 403 or something similar so that me (as a client) can notify the user that it wasn't successful.

System information

  • Version of supabase-js: the last one
  • Version of Node.js: 14
@n-sviridenko n-sviridenko added the bug Something isn't working label Oct 17, 2022
@soedirgo
Copy link
Member

This is working as intended - a 403 is not sufficient from a security perspective since that leaks the existence of the row.

To determine whether or not a .delete() actually has rows deleted, you can do a .delete() with .select() which returns the deleted rows, if any.

@steve-chavez
Copy link
Member

You can also use single() to err if you expect deleting a single row, this will be logged with a 406 Not Acceptable.

Additionally if you revoke the DELETE privilege

REVOKE DELETE ON <tbl> FROM authenticated;

You'll always get a 403 when using delete().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants