Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Category: Task » Bug report
Status: Active » Needs review
StatusFileSize
new2.71 KB
wim leers’s picture

StatusFileSize
new1.93 KB
new4.6 KB

To make this work, we'll need to ensure that the User entity's pass field does get set even when editing it is not allowed.

wim leers’s picture

Title: Module forbidding the 'edit' operation on the User entity's 'pass' field would prevent editing security-sensitive base fields » [PP-1] Module forbidding the 'edit' operation on the User entity's 'pass' field would prevent editing security-sensitive base fields
Status: Needs review » Postponed
wim leers’s picture

#2 will have failed at

    // DX: 422 when changing email while providing a wrong password.
    $response = $this->request('PATCH', $url, $request_options);
    $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n", $response, FALSE, FALSE, FALSE, FALSE);

With #3, the failure will have shifted down a few dozen lines in the test scenario, to:

    // DX: 422 when changing password without providing the current password.
    $response = $this->request('PATCH', $url, $request_options);
    $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\npass: Your current password is missing or incorrect; it's required to change the Password.\n", $response, FALSE, FALSE, FALSE, FALSE);

    $normalization['pass'][0]['existing'] = $this->account->pass_raw;
    $request_options[RequestOptions::BODY] = $this->serializer->encode($normalization, static::$format);

IOW: thanks to #3, at least // Test case 1: changing email. can be completed successfully. But // Test case 2: changing password. fails.

Why?

Because \Drupal\rest\Plugin\rest\resource\EntityResource::patch() calls \Drupal\rest\Plugin\rest\resource\EntityResourceValidationTrait::validate(), which calls $violations->filterByFieldAccess();… and since the pass field cannot be edited according to the field access checking, there also shouldn't be any validation errors for it.

But of course, #3 does allow the pass field to be set (although only to be able to check that the correct password was provided when modifying security-sensitive fields: mail, name and pass) … which is how you're effectively able to bypass security, thanks to the patch in #3 (not in HEAD).

wim leers’s picture

If you want to confirm #5 yourself, add this debug output:

diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResourceValidationTrait.php b/core/modules/rest/src/Plugin/rest/resource/EntityResourceValidationTrait.php
index 09b4b64..edd29e1 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResourceValidationTrait.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResourceValidationTrait.php
@@ -29,10 +29,14 @@ protected function validate(EntityInterface $entity) {
     }
     $violations = $entity->validate();
 
+    var_dump($violations->getFieldNames());
+
     // Remove violations of inaccessible fields as they cannot stem from our
     // changes.
     $violations->filterByFieldAccess();
 
+    var_dump($violations->getFieldNames());
+
     if ($violations->count() > 0) {
       $message = "Unprocessable Entity: validation failed.\n";
       foreach ($violations as $violation) {

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed » Needs work
Issue tags: +Bug Smash Initiative, +Needs issue summary update, +Needs reroll

This issue this was postponed on was committed to Drupal 8.5.x

This needs an issue summary update and reroll.

quietone’s picture

Title: [PP-1] Module forbidding the 'edit' operation on the User entity's 'pass' field would prevent editing security-sensitive base fields » Module forbidding the 'edit' operation on the User entity's 'pass' field would prevent editing security-sensitive base fields
immaculatexavier’s picture

Assigned: Unassigned » immaculatexavier
immaculatexavier’s picture

Assigned: immaculatexavier » Unassigned
immaculatexavier’s picture

Status: Needs work » Needs review
StatusFileSize
new4.14 KB
new4.31 KB

Rerolled patch against #3.

ranjith_kumar_k_u’s picture

StatusFileSize
new3.77 KB
new2.09 KB

Status: Needs review » Needs work

The last submitted patch, 21: 2930182-21.patch, failed testing. View results

tvb’s picture

Issue tags: -Needs reroll

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.41 KB
new3.77 KB

Fixed the test failures on 10.1.x

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new2.79 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

pooja saraah’s picture

StatusFileSize
new3.73 KB
new1.79 KB

Fixed failed commands on #25
Attached patch against Drupal 10.1.x

pooja saraah’s picture

Status: Needs work » Needs review
smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

For the issue summary requested in #16.

Fyi rerolls should not be put into review when there are outstanding issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.