Background information
- confidential private issue: https://git.drupalcode.org/security/183454-drupal-security/-/work_items/1
(included for reference. Please do not report access denied as an error.)
Problem/Motivation
form.js passes user input to $():
const $target = $(`#${hash}`);
I don't think this can be exploited in modern jQuery, it triggers a syntax error if hash is not a valid ID selector.
However passing unsanitized user input to $() is a bad practice, we should probably sanitize the hash to make sure it does not contain dangerous characters.
Steps to reproduce
Proposed resolution
An easy fix could be to use document.getElementById() to make sure the hash is interpreted as an ID.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3617238
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 #3
prudloff commentedComment #4
longwaveNot exactly the same issue but closely related to #2395065: Certain URL fragments cause javascript error
Comment #5
longwaveActually I think this is the same issue and this solves it in a better way, we could port the test from there to here.
Comment #7
longwavePorted the test from the linked issue, and added a happy path test while I was there, as this functionality previously had no test coverage that I could see.
Comment #8
smustgrave commentedRan the test-only for the ported tests
Not sure if #2395065: Certain URL fragments cause javascript error should be closed? That ticket does 1 more change but with the test coverage added here that issue isn't appearing.
Will let committer decide.