DraggableListBuilder::buildForm() includes the following code:

      $row = $this->buildRow($entity);
      if (isset($row['label'])) {
        $row['label'] = array('#markup' => $row['label']);
      }

Implementations of buildRow() are expected to set $row['label']; in core, at least SearchPageListBuilder and RoleListBuilder do this. If the entity label contains an HTML tag, it is not escaped. I don't think this is a security issue as it seems to be filtered for XSS and I could not manage to execute any JavaScript but it still allows unexpected HTML to be output.

To reproduce this simply create a search page or role with an HTML tag such as <b> in the label and view the listing page.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Issue summary: View changes
longwave’s picture

Priority: Major » Normal
Status: Active » Needs review
FileSize
722 bytes

#plain_text seems a better choice than #markup.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

Kristen Pol’s picture

Hmm... maybe I'm misunderstanding. I added a search page without the patch and with the patch and put <b> around the label text but I see the markup around the text in the tab in both cases.

Kristen Pol’s picture

Issue tags: +Bug Smash Initiative
joachim’s picture

> view the listing page

That means go to the admin list of search pages, not the search page itself.

Kristen Pol’s picture

Ah, right. In both cases for me, they showed up as bold. So maybe this has been fixed.

And the tab issue seems like a bug

Kristen Pol’s picture

Forgot to include screenshots of listing page.

Kristen Pol’s picture

Version: 8.9.x-dev » 9.1.x-dev
Kristen Pol’s picture

Issue tags: +Needs reroll

Ok, I think I see what's going on. The patch doesn't apply to 9.0.x or 9.1.x. I was using simplytest.me and it didn't complain about the patch not applying. Needs a reroll. Sorry for the confusion.

Kristen Pol’s picture

Status: Needs review » Needs work
mrinalini9’s picture

Status: Needs work » Needs review
FileSize
718 bytes

Rerolled patch #3 for 9.1.x branch, please review.

joachim’s picture

> In both cases for me, they showed up as bold

According to the IS, they shouldn't though -- the B tag in the config entity label shouldn't result in actual HTML shown in the admin listing.

longwave’s picture

Issue tags: -Needs reroll +Needs tests

We need a test to cover this now.

idebr’s picture

Attached patch adds test coverage.

Interdiff = 2656570-23-test-only.patch

The last submitted patch, 23: 2656570-23-test-only.patch, failed testing. View results

Kristen Pol’s picture

@joachim Regarding

"According to the IS, they shouldn't though -- the B tag in the config entity
label shouldn't result in actual HTML shown in the admin listing"

Yeah. I realized that after I made that comment and forgot to update it. Sorry for the confusion. I was thrown off by the tab showing markup.

Kristen Pol’s picture

Thanks for the update.

1) Test code is clear and tests the issue in question.

2) Patch still applies cleanly.

3) Tests pass.

4) Test-only test fails as expected.

5) Manual testing was successful (see screenshots).

Marking RTBC!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

So this is definitely the correct behaviour for roles - the title is escape on the user account checkboxes and the permissions page. Wondering if this can be said to be generically true for all config entity labels - especially ones a non admin user might see. For example - vocabulary names. So the vocab label is not escaped in the title for the vocab page. And it's not escaped on the entity reference field checkbox. But if you enable layout and add a block to display the vocabulary label it is escaped. I love titles and escaping. Always inconsistent.

I guess the most important place to check is menus because this is a place people often use html in labels. So if you create a label with html in it - it's escaped on the page you can sort the menu list and it is escaped in the menu.

Given the above I think this fix is correct. Escaping html in here makes sense since the labels are used a drag handles so you don't want links to get in the way and this shouldn't affect the disable of labels in a non draggable situation. Given there is no security issue here - this is used in admin situations and we have XSS filtering I'm going to commit this to 9.1.x only just in case this has an unexpected effect. There are many more types of config entities than what I checked.

Committed 687dcd4 and pushed to 9.1.x. Thanks!

  • alexpott committed 687dcd4 on 9.1.x
    Issue #2656570 by idebr, longwave, mrinalini9, Kristen Pol, joachim:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.