Problem/Motivation

Especially with the growth of Features, and the ability to use update module to add/update themes and modules, it seems like a not entirely safe assumption that what's in the .info file is safe text.

Also, there are modules that let you write themes, for example, via a starting from an existing theme as a template. In that case, a user with a lesser admin permission might be able to inject XSS.

We should sanitize all the elements of the .info file that may be displayed (or maybe just all) as a simple hardening.

Steps to reproduce

Create any module like(module_name) , add .info.yml file for eg(module_name.info.yml)

In module_name.info.yml, in the description of module name add script code like this :
description: <script>alert('evil desc');</script>

Now hit the /admin/modules page

You 'll notice script execute
module-script

Expected behaviour

If in description of module name added script code like this:
description: <script>alert('evil desc');</script>

then script code should not execute.

Proposed resolution

Sanitize all the elements of the .info file that may be displayed.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-637538

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

greggles’s picture

We should sanitize all the elements of te .info file that may be displayed on output, as they are output as a simple hardening.

Agreed :)

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new2.75 KB

Here's a first pass

meba’s picture

StatusFileSize
new2.91 KB

This no longer applied, rerolling.

Since I would like to see all of these silly XSS bugs in core gone, should this be critical?

casey’s picture

Status: Needs review » Needs work

http://api.drupal.org/api/function/t/7

@variable: Indicates that the text should be run through check_plain(), to escape HTML characters.

You shouldn't call check_plain() on @module and @version manually.

aaronbauman’s picture

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

Removed extraneous check_plain()s
Edited patch by hand - let's see if it passes.

Status: Needs review » Needs work

The last submitted patch, 637538-5_info_xss.patch, failed testing.

aaronbauman’s picture

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

and again

Status: Needs review » Needs work

The last submitted patch, 637538-7_info_xss.patch, failed testing.

aaronbauman’s picture

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

are you complaining about the name of my file, testbot?
otherwise, i'm out of ideas

Status: Needs review » Needs work

The last submitted patch, info_xss-637538-9.patch, failed testing.

eric_a’s picture

Windows newlines...

aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB

silly me - I figured I wouldn't have to worry about Windows newlines since I'm on a Mac.

mr.baileys’s picture

#12: info_xss-637538-12.patch queued for re-testing.

mr.baileys’s picture

StatusFileSize
new2.41 KB
  • Re-rolled to keep up with head
  • Added check_plain() for the package property which was missing from the previous patch.

Status: Needs review » Needs work

The last submitted patch, 637538-fix-module-list-xss.patch, failed testing.

bas.hr’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Needs review

Patch mr.baileys wrote is for D8

bas.hr’s picture

StatusFileSize
new2.41 KB
greggles’s picture

Status: Needs review » Needs work

This no longer applies.

greggles’s picture

Issue tags: +Needs backport to D7
greggles’s picture

Issue tags: +Needs backport to D6
greggles’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new3.82 KB

Removing all the old files to focus on 8.x. Here's a start at updating this to 8.x.

Status: Needs review » Needs work

The last submitted patch, 21: 637538_filter_info_files.patch, failed testing.

mr.baileys’s picture

StatusFileSize
new3.45 KB

Straight reroll.

mr.baileys’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: 637538_23_filter_info_files.patch, failed testing.

mr.baileys’s picture

Status: Needs work » Needs review
StatusFileSize
new4.33 KB
new4.33 KB
  • Added a missing use-stagement
  • Theme description was not yet sanitized, added
mr.baileys’s picture

mgifford’s picture

Status: Needs review » Needs work

Needs re-roll.

rteijeiro’s picture

Status: Needs work » Needs review
StatusFileSize
new3.36 KB

Re-rolled!

Status: Needs review » Needs work

The last submitted patch, 29: 637538_29_filter_info_files_0.patch, failed testing.

rteijeiro’s picture

Status: Needs work » Needs review
StatusFileSize
new3.52 KB

Fixed missing `use` statement.

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.

quietone credited dawehner.

quietone’s picture

Version: 8.9.x-dev » 9.3.x-dev
Component: base system » extension system
Issue summary: View changes
Issue tags: -Needs backport to D6

Closed #2527544: Module list page is not XSS safe as a duplicate of this issue. Adding credit - it is worth checking if I did that correctly.

There is more discussion in that issue about the problem space. I'll just put the summary of that discussion, by cilefen here,

Arguably, there is no reason not to sanitize these but the threat model is so small this should be normal priority. #2 made the point that if you have a malicious YAML file you could also have malicious PHP and how would this help then?

quietone credited humansky.

quietone credited sime.

quietone’s picture

Closed #846430: Run filter_xss() over .info values as a duplicate, adding credit.

ranjith_kumar_k_u’s picture

StatusFileSize
new3.49 KB

Re-rolled the last patch for 9.3

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.

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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new143 bytes

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.

nikhil_110’s picture

StatusFileSize
new4.01 KB

Attached patch against Drupal 10.1.x

Patch #46 is not applied for Drupal 10 so Inter-diff file is not added.

Checking patch core/modules/system/src/Form/ModulesListForm.php...
Hunk #1 succeeded at 21 (offset 1 line).
Hunk #2 succeeded at 143 (offset 3 lines).
Hunk #3 succeeded at 208 (offset 8 lines).
error: while searching for:
$row['#requires'] = [];
$row['#required_by'] = [];

$row['name']['#markup'] = $module->info['name'];
$row['description']['#markup'] = $this->t($module->info['description']);
$row['version']['#markup'] = $module->info['version'];

// Generate link for module's help page. Assume that if a hook_help()
// implementation exists then the module provides an overview page, rather

error: patch failed: core/modules/system/src/Form/ModulesListForm.php:247
error: core/modules/system/src/Form/ModulesListForm.php: patch does not apply
Checking patch core/modules/system/system.admin.inc...

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.

Bhanu951 made their first commit to this issue’s fork.

bhanu951’s picture

Status: Needs work » Needs review

Came from http://www.madirish.net/555

Re-Rolled patch from #46 against 11.x head.

needs-review-queue-bot’s picture

Status: Needs review » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

pooja_sharma made their first commit to this issue’s fork.

pooja_sharma’s picture

Addressed the test failures & pipeline passed

Please review , moved NR

pooja_sharma’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks for continuing to work on this. Will need a test case showing the issue.

pooja_sharma’s picture

Added test case .

Please review , moved NR

pooja_sharma’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Have not reviewed yet but issue summary appears to be incomplete could that be updated please

Can use https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-.... for help if needed.

pooja_sharma’s picture

Issue summary: View changes
StatusFileSize
new115.15 KB

Issue summary updated w.r.t to standard issue template.

Please review, moved NR

pooja_sharma’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests +Needs Review Queue Initiative

Hiding all patches for clarity

Ran test-only feature which gve

1) Drupal\Tests\system\FunctionalJavascript\PageXssVulnerabilityTest::testPageLoadWithoutXss
WebDriver\Exception\UnexpectedAlertOpen: unexpected alert open: {Alert text : evil desc}
  (Session info: headless chrome=106.0.5249.103)
  (Driver info: chromedriver=106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}),platform=Linux 5.4.266-178.365.amzn2.x86_64 x86_64)
/builds/issue/drupal-637538/vendor/lullabot/php-webdriver/lib/WebDriver/Exception.php:198
/builds/issue/drupal-637538/vendor/lullabot/php-webdriver/lib/WebDriver/AbstractWebDriver.php:216
/builds/issue/drupal-637538/vendor/lullabot/php-webdriver/lib/WebDriver/AbstractWebDriver.php:287
/builds/issue/drupal-637538/vendor/lullabot/php-webdriver/lib/WebDriver/Container.php:231
/builds/issue/drupal-637538/vendor/lullabot/php-webdriver/lib/WebDriver/Session.php:579
/builds/issue/drupal-637538/vendor/lullabot/mink-selenium2-driver/src/Selenium2Driver.php:541
/builds/issue/drupal-637538/core/tests/Drupal/Tests/DocumentElement.php:41
/builds/issue/drupal-637538/core/tests/Drupal/Tests/UiHelperTrait.php:261
/builds/issue/drupal-637538/core/modules/system/tests/src/FunctionalJavascript/PageXssVulnerabilityTest.php:44
ERRORS!
Tests: 1, Assertions: 6, Errors: 1.

Removing that tag

Left some comments on the MR

pooja_sharma’s picture

Addressed the mentioned feedbacks & rebased the MR

Please review, move NR.

pooja_sharma’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs backport to D7, -Needs issue summary update

I couldn't find a better place for this test so think it's own file should be fine.

pooja_sharma’s picture

Rebased the MR with latest code, seems working fine

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Added some comments to the MR.

pooja_sharma’s picture

Applied the mentioned suggestions.

Please review, moving NR

pooja_sharma’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe feedback has been addressed

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Added some more review comments to address.

pooja_sharma’s picture

Applied mentioned suggestion to the MR.

Please review, moving NR

pooja_sharma’s picture

Status: Needs work » Needs review
pooja_sharma’s picture

Applied the mentioned suggestion & left some comments for some feedbacks.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new790.31 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

pooja_sharma’s picture

Rebased MR with latest code & applied the left suggestion as well.

Please review, moving NR.

pooja_sharma’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

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

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

pooja_sharma’s picture

Status: Needs work » Needs review

Addressed test failures & pipeline passed successfully.

Please review, moving NR.

hetal.solanki’s picture

Status: Needs review » Reviewed & tested by the community

@all
I have reviewed MR !7436. It's looks good.
Moving to RTBC.
Thank you!!

amanbtr72’s picture

pooja_sharma’s picture

Status: Reviewed & tested by the community » Needs review

To maintain consistency some minor changes done

Please review, moving NR

amanbtr72’s picture

Status: Needs review » Reviewed & tested by the community

Re-viewed the changes in the recent MR, Looks good.

Moving to RTBC+1

pooja_sharma’s picture

Only Rebased the MR with latest code, keeping it to the prev RTBC status

alexpott’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 4c82b7eaac to 11.x and 80833d6441 to 11.0.x and 62fb919925 to 10.4.x and 9a57269327 to 10.3.x. Thanks!

  • alexpott committed 9a572693 on 10.3.x
    Issue #637538 by pooja_sharma, mr.baileys, AaronBauman, Bhanu951,...

  • alexpott committed 62fb9199 on 10.4.x
    Issue #637538 by pooja_sharma, mr.baileys, AaronBauman, Bhanu951,...

  • alexpott committed 80833d64 on 11.0.x
    Issue #637538 by pooja_sharma, mr.baileys, AaronBauman, Bhanu951,...

  • alexpott committed 4c82b7ea on 11.x
    Issue #637538 by pooja_sharma, mr.baileys, AaronBauman, Bhanu951,...

Status: Fixed » Closed (fixed)

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