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
| Comment | File | Size | Author |
|---|---|---|---|
| #82 | 637538-nr-bot.txt | 2.1 KB | needs-review-queue-bot |
| #79 | 637538-nr-bot.txt | 790.31 KB | needs-review-queue-bot |
Issue fork drupal-637538
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
Comment #1
gregglesWe should sanitize all the elements of te .info file that may be displayed on output, as they are output as a simple hardening.
Agreed :)
Comment #2
pwolanin commentedHere's a first pass
Comment #3
meba commentedThis no longer applied, rerolling.
Since I would like to see all of these silly XSS bugs in core gone, should this be critical?
Comment #4
casey commentedhttp://api.drupal.org/api/function/t/7
You shouldn't call check_plain() on @module and @version manually.
Comment #5
aaronbaumanRemoved extraneous check_plain()s
Edited patch by hand - let's see if it passes.
Comment #7
aaronbaumanand again
Comment #9
aaronbaumanare you complaining about the name of my file, testbot?
otherwise, i'm out of ideas
Comment #11
eric_a commentedWindows newlines...
Comment #12
aaronbaumansilly me - I figured I wouldn't have to worry about Windows newlines since I'm on a Mac.
Comment #13
mr.baileys#12: info_xss-637538-12.patch queued for re-testing.
Comment #14
mr.baileysComment #16
bas.hr commentedPatch mr.baileys wrote is for D8
Comment #17
bas.hr commentedComment #18
gregglesThis no longer applies.
Comment #19
gregglesComment #20
gregglesComment #21
gregglesRemoving all the old files to focus on 8.x. Here's a start at updating this to 8.x.
Comment #23
mr.baileysStraight reroll.
Comment #24
mr.baileysComment #26
mr.baileysuse-stagementComment #27
mr.baileysComment #28
mgiffordNeeds re-roll.
Comment #29
rteijeiro commentedRe-rolled!
Comment #31
rteijeiro commentedFixed missing `use` statement.
Comment #42
quietone commentedClosed #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,
Comment #45
quietone commentedClosed #846430: Run filter_xss() over .info values as a duplicate, adding credit.
Comment #46
ranjith_kumar_k_u commentedRe-rolled the last patch for 9.3
Comment #50
needs-review-queue-bot commentedThe 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.
Comment #51
nikhil_110 commentedAttached patch against Drupal 10.1.x
Patch #46 is not applied for Drupal 10 so Inter-diff file is not added.
Comment #55
bhanu951 commentedCame from http://www.madirish.net/555
Re-Rolled patch from #46 against 11.x head.
Comment #56
needs-review-queue-bot commentedThe 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.)
Comment #58
pooja_sharma commentedAddressed the test failures & pipeline passed
Please review , moved NR
Comment #59
pooja_sharma commentedComment #60
smustgrave commentedThanks for continuing to work on this. Will need a test case showing the issue.
Comment #61
pooja_sharma commentedAdded test case .
Please review , moved NR
Comment #62
pooja_sharma commentedComment #63
smustgrave commentedHave 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.
Comment #64
pooja_sharma commentedIssue summary updated w.r.t to standard issue template.
Please review, moved NR
Comment #65
pooja_sharma commentedComment #66
smustgrave commentedHiding all patches for clarity
Ran test-only feature which gve
Removing that tag
Left some comments on the MR
Comment #67
pooja_sharma commentedAddressed the mentioned feedbacks & rebased the MR
Please review, move NR.
Comment #68
pooja_sharma commentedComment #69
smustgrave commentedI couldn't find a better place for this test so think it's own file should be fine.
Comment #70
pooja_sharma commentedRebased the MR with latest code, seems working fine
Comment #71
alexpottAdded some comments to the MR.
Comment #72
pooja_sharma commentedApplied the mentioned suggestions.
Please review, moving NR
Comment #73
pooja_sharma commentedComment #74
smustgrave commentedBelieve feedback has been addressed
Comment #75
alexpottAdded some more review comments to address.
Comment #76
pooja_sharma commentedApplied mentioned suggestion to the MR.
Please review, moving NR
Comment #77
pooja_sharma commentedComment #78
pooja_sharma commentedApplied the mentioned suggestion & left some comments for some feedbacks.
Comment #79
needs-review-queue-bot commentedThe 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.
Comment #80
pooja_sharma commentedRebased MR with latest code & applied the left suggestion as well.
Please review, moving NR.
Comment #81
pooja_sharma commentedComment #82
needs-review-queue-bot commentedThe 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.
Comment #83
pooja_sharma commentedAddressed test failures & pipeline passed successfully.
Please review, moving NR.
Comment #84
hetal.solanki@all
I have reviewed MR !7436. It's looks good.
Moving to RTBC.
Thank you!!
Comment #85
amanbtr72 commentedComment #86
pooja_sharma commentedTo maintain consistency some minor changes done
Please review, moving NR
Comment #87
amanbtr72 commentedRe-viewed the changes in the recent MR, Looks good.
Moving to RTBC+1
Comment #88
pooja_sharma commentedOnly Rebased the MR with latest code, keeping it to the prev RTBC status
Comment #89
alexpottCommitted 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!