Module and theme names are not filtered on output.

Created on 19 November 2009, about 15 years ago
Updated 13 August 2024, 4 months ago

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

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

🐛 Bug report
Status

Fixed

Version

10.3

Component
Extension 

Last updated 9 days ago

No maintainer
Created by

🇺🇸United States pwolanin

Live updates comments and jobs are added and updated live.
  • Security improvements

    It makes Drupal less vulnerable to abuse or misuse. Note, this is the preferred tag, though the Security tag has a large body of issues tagged to it. Do NOT publicly disclose security vulnerabilities; contact the security team instead. Anyone (whether security team or not) can apply this tag to security improvements that do not directly present a vulnerability e.g. hardening an API to add filtering to reduce a common mistake in contributed modules.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 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.

  • 🇮🇳India nikhil_110

    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...

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.2 & sqlite-3.34
    last update about 1 year ago
    29,506 pass, 62 fail
  • First commit to issue fork.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India bhanu951

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

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

  • Pipeline finished with Canceled
    9 months ago
    Total: 223s
    #143588
  • Status changed to Needs work 9 months ago
  • 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.)

  • Pipeline finished with Failed
    9 months ago
    Total: 991s
    #143596
  • First commit to issue fork.
  • Pipeline finished with Failed
    6 months ago
    Total: 542s
    #198079
  • Pipeline finished with Failed
    6 months ago
    Total: 588s
    #198099
  • Pipeline finished with Success
    6 months ago
    Total: 510s
    #198105
  • Addressed the test failures & pipeline passed

    Please review , moved NR

  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 6 months ago
  • 🇺🇸United States smustgrave

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

  • Pipeline finished with Success
    6 months ago
    Total: 574s
    #202893
  • Pipeline finished with Success
    6 months ago
    #202907
  • Pipeline finished with Success
    6 months ago
    Total: 517s
    #202926
  • Pipeline finished with Success
    6 months ago
    Total: 605s
    #202946
  • Added test case .

    Please review , moved NR

  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 6 months ago
  • 🇺🇸United States smustgrave

    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.

  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 6 months ago
  • 🇺🇸United States smustgrave

    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

  • Pipeline finished with Success
    6 months ago
    Total: 616s
    #209979
  • Pipeline finished with Canceled
    6 months ago
    Total: 381s
    #209997
  • Pipeline finished with Success
    6 months ago
    Total: 509s
    #210004
  • Pipeline finished with Success
    6 months ago
    Total: 529s
    #210023
  • Addressed the mentioned feedbacks & rebased the MR

    Please review, move NR.

  • Status changed to Needs review 6 months ago
  • Status changed to RTBC 6 months ago
  • 🇺🇸United States smustgrave

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

  • Pipeline finished with Success
    6 months ago
    Total: 908s
    #216754
  • Rebased the MR with latest code, seems working fine

  • Status changed to Needs work 5 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Added some comments to the MR.

  • Pipeline finished with Success
    5 months ago
    Total: 607s
    #222275
  • Applied the mentioned suggestions.

    Please review, moving NR

  • Status changed to Needs review 5 months ago
  • Status changed to RTBC 5 months ago
  • 🇺🇸United States smustgrave

    Believe feedback has been addressed

  • Status changed to Needs work 5 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Added some more review comments to address.

  • Pipeline finished with Canceled
    5 months ago
    Total: 192s
    #227092
  • Pipeline finished with Success
    5 months ago
    Total: 528s
    #227097
  • Pipeline finished with Canceled
    5 months ago
    Total: 207s
    #227103
  • Pipeline finished with Canceled
    5 months ago
    Total: 164s
    #227109
  • Pipeline finished with Failed
    5 months ago
    Total: 736s
    #227111
  • Pipeline finished with Canceled
    5 months ago
    Total: 94s
    #227136
  • Pipeline finished with Success
    5 months ago
    Total: 499s
    #227137
  • Pipeline finished with Success
    5 months ago
    Total: 786s
    #227153
  • Applied mentioned suggestion to the MR.

    Please review, moving NR

  • Status changed to Needs review 5 months ago
  • Pipeline finished with Success
    5 months ago
    Total: 896s
    #227835
  • Applied the mentioned suggestion & left some comments for some feedbacks.

  • Pipeline finished with Success
    5 months ago
    Total: 492s
    #230847
  • Status changed to Needs work 5 months ago
  • 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.

  • Pipeline finished with Success
    5 months ago
    Total: 518s
    #230871
  • Rebased MR with latest code & applied the left suggestion as well.

    Please review, moving NR.

  • Status changed to Needs review 5 months ago
  • Status changed to Needs work 5 months ago
  • 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.

  • Pipeline finished with Canceled
    5 months ago
    Total: 62s
    #231017
  • Pipeline finished with Success
    5 months ago
    Total: 487s
    #231021
  • Status changed to Needs review 5 months ago
  • Addressed test failures & pipeline passed successfully.

    Please review, moving NR.

  • Status changed to RTBC 5 months ago
  • 🇮🇳India hetal.solanki

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

  • Pipeline finished with Canceled
    5 months ago
    Total: 31s
    #231227
  • Pipeline finished with Success
    5 months ago
    Total: 476s
    #231228
  • Status changed to Needs review 5 months ago
  • To maintain consistency some minor change done

    Please review, moving NR

  • Status changed to RTBC 5 months ago
  • 🇮🇳India amanbtr72

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

    Moving to RTBC+1

  • Pipeline finished with Success
    5 months ago
    Total: 467s
    #238125
  • Only Rebased the MR with latest code, keeping it to the prev RTBC status

  • Status changed to Fixed 5 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    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,...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024