parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.84k stars 4.77k forks source link

Embedded document modification requires addField permission #7371

Open mstniy opened 3 years ago

mstniy commented 3 years ago

New Issue Checklist

Issue Description

Using PUT to modify a nested document fails unless the caller has addField permissions, even if the request doesn't add a new field.

Steps to reproduce

  1. Create a new class, nested_test.
  2. Remove public addField permission from the class.
  3. Use PUSH to create this object: { "a": {"b":1}}
  4. Use PUT to change the 1 to a 2 : {"a.b": 4}
  5. Observer that the operation fails due to a lack of addField permission.
  6. Grant addField to the public for the class.
  7. Observe that the request now successfully modifies the nested key.

Actual Outcome

The first PUT request should succeed, even without the addField permission, because it does not add a new field.

Expected Outcome

It fails due to a lack of addField permission.

Failing Test Case / Pull Request

Environment

Server

Database

Client

Logs

mstniy commented 3 years ago

6687 may be related

mtrezza commented 3 years ago

Thanks for reporting!

I label this as needs more info until the test in the PR ails and confirms that this does not work.

I changed to title to be specific about adding a new object key. If I understand correctly, modifying an existing key does not require "add field" permission.

mstniy commented 3 years ago

If I understand correctly, modifying an existing key does not require "add field" permission.

It indeed does, if one tries to modify a key of a nested document.

mtrezza commented 3 years ago

So the issue occurs when modifying an existing key and when adding a new key?

mstniy commented 3 years ago

When modifying a nested object, no matter whether you are introducing a new key to the nested object or modifying a key that already exists.

mtrezza commented 3 years ago

Thanks for clarifying, so I commented on your PR to include tests for both scenarios.