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

Writing null to non-existent node triggers create() validation #248

Open
dotdoom opened this issue Sep 15, 2019 · 0 comments
Open

Writing null to non-existent node triggers create() validation #248

dotdoom opened this issue Sep 15, 2019 · 0 comments

Comments

@dotdoom
Copy link

dotdoom commented Sep 15, 2019

With the following rules:

objectAccess(objectId) {
  root.object_access[objectId][auth.uid]
}

path /shared/{userId}/{objectId} is Obj {
  create() {
    objectAccess(objectId) === "owner" &&
    this.sharing_accepted_by_receiver == false
  }
  <...>
}

And database looking like:

{
  "object_access": {
    "obj1": {
      "user1": "owner",
      "user2": "read",
    }
  }
}

There are 2 pitfalls I have encountered so far:

  • "un-sharing" scenario: writing

    /shared/user2/obj1 = null
    /object_access/obj1/user2 = null
    

    triggers create() even though that node is not being created, subsequently failing on sharing_accepted_by_receiver == false;

  • "deleting" scenario: writing

    /shared/user2/obj1 = null
    /object_access/obj1 = null
    

    triggers create() even though that node is not being created, subsequently failing on objectAccess === "owner".

Is this expected behavior? I'd expect in this case to skip all of CRUD alltogether and allow the write.

I understand that this may allow certain "probing" of the database by malicious users (to find null values), but it's still counter-intuitive and should likely be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant