Follow-up to #2338081: Local Tasks, Actions, and Contextual links mark strings from derivatives (or alter hooks) as safe and translated

This XSS is fixed in the parent issue. The purpose of this issue is to add a regression test.

Here are the steps to reproduce the XSS attack.

  • Give user A permission 'administer search'
  • As user A go to /admin/config/search/pages/manage/node_search
  • Enter script in label textfield.
  • As any user visit /search to trigger the script

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it is a follow-up regression test on a critical bug.
Issue priority Major because it is a security regression test and a follow-up to a critical issue.
Unfrozen changes Unfrozen because it only changes tests.

Comments

brandon.holtsclaw’s picture

I'm at DrupalGovCon and working on this test.

brandon.holtsclaw’s picture

Status: Active » Needs review
StatusFileSize
new1.7 KB

This test will fail until the parent issue is committed.

Status: Needs review » Needs work

The last submitted patch, 2: 2539246-1.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review

cilefen queued 2: 2539246-1.patch for re-testing.

brandon.holtsclaw queued 2: 2539246-1.patch for re-testing.

brandon.holtsclaw’s picture

So if I'm understanding whats going on here correctly ... this is passing on the old testbots but is failing on the new testbots, the link https://www.drupal.org/node/3060/qa shows that core IS passing on "PHP 5.5 & MySQL 5.5 12,999 pass"

So I'd like to investigate this further but I do not know how to find out the exact PHP 5.5 versions that are running on the old and new testbots.

brandon.holtsclaw’s picture

After a little prodding on the issue, it seems that it was just non-obvious that when you click "retest" , its ONLY for the old testbot and I had wrongly assumed it would kick off a retest for both. After telling the new testbot to kick-off again against PHP 5.5 all seems to be right with the world.

So this is now fully ready for review & commit.

cilefen’s picture

This is a nice regression test. +1 for RTBC. One minor thing:

+++ b/core/modules/search/src/Tests/SearchPageTextTest.php
@@ -135,6 +163,6 @@ function testSearchText() {
-
   }
 }
+

These line changes at the end of the test class should be removed in the next patch.

brandon.holtsclaw’s picture

StatusFileSize
new1.36 KB

I've removed the changes at the end of the patch per suggestion from @cilefen

Status: Needs review » Needs work

The last submitted patch, 10: 2539246-10.patch, failed testing.

brandon.holtsclaw’s picture

StatusFileSize
new1.37 KB

re-rolling last patch that did not apply cleanly to head

brandon.holtsclaw’s picture

Status: Needs work » Needs review
brandon.holtsclaw’s picture

Status: Needs review » Reviewed & tested by the community
cilefen’s picture

Status: Reviewed & tested by the community » Needs review

@brandon.holtsclaw It is good work, but it needs peer review.

cilefen’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I added the beta evaluation. The #12 patch tests exactly what is needed—an XSS vulnerability that was fixed in the parent issue.

It is not possible to reproduce the problem any more, however, early versions of this patch failed (as they should) before the parent was committed.

The code looks good, and the changes are in-scope. It expands test coverage to prevent a regression.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/search/src/Tests/SearchPageTextTest.php
    @@ -23,11 +23,40 @@ class SearchPageTextTest extends SearchTestBase {
    +
    +  }
    ...
    +
       }
    

    The blank lines before the method close curly brace is not necessary.

  2. +++ b/core/modules/search/src/Tests/SearchPageTextTest.php
    @@ -23,11 +23,40 @@ class SearchPageTextTest extends SearchTestBase {
    +    $this->cronRun();
    +
    +    $this->drupalLogout();
    

    I don't think these steps are necessary.

brandon.holtsclaw’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB
new1.18 KB

I've updated the patch per the comments from alexpott in #17 and included and interdiff

brandon.holtsclaw’s picture

StatusFileSize
new1.67 KB
new1.09 KB

Here is a new interdiff and patch per feedback on IRC from alexpott

Status: Needs review » Needs work

The last submitted patch, 19: 2539246-19.patch, failed testing.

brandon.holtsclaw’s picture

Status: Needs work » Needs review
StatusFileSize
new1.25 KB
new1.36 KB

One more patch to fix the syntax error and to remove the admin user ... this should have been in the last patch :(

pwolanin’s picture

Component: menu system » search.module

Changing the component since while this is a regression test against the local task system, the test is under the search module.

Test code looks good and patch seems to have taken all the feedback into account.

Minor additional code comment cleanup I'd suggest:

minor:
"Tests for XSS in search module local menu task label." -> either "menu local task" or just "local task" I think.

it might also be helpful to add a note about where the original bug was fixed

Similar to core/modules/user/src/Tests/UserRegistrationTest.php which has:

 * This is a regression test for https://www.drupal.org/node/2500527 to ensure
 * that the form is not cached on GET requests.
brandon.holtsclaw’s picture

StatusFileSize
new1.31 KB
new637 bytes

Here is a new interdiff and patch that incorporates the feedback from pwolanin in #22

pwolanin’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, this looks like a good addition to the tests.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 93cb20d and pushed to 8.0.x. Thanks!

  • alexpott committed 93cb20d on 8.0.x
    Issue #2539246 by brandon.holtsclaw, cilefen, pwolanin: Search page...

Status: Fixed » Closed (fixed)

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

gábor hojtsy’s picture

Issue tags: -sprint