Problem/Motivation
The drupal_youtube service does not sanitize attribute values and is vulnerable to an XSS vulnerability.
Steps to reproduce
- Enable the drupal_youtube service.
- Create a text format that allows
divtags withclassanddata-widthattributes (but not thedata-onloadattribute). - Create a node using this text format and insert this HTML in the field:
<div class="youtube_player" data-width="" onload="alert(`xss`);"">Foo</div> - The width attribute is not sanitized when building the iframe so the onload attribute is injected (thus bypassing the attribute restrictions from the text format).
Proposed resolution
I think Drupal.checkPlain() can be used to sanitize the attribute.
But the best practice is probably to build the iframe with DOM functions like createElement() and setAttribute().
Issue fork tarte_au_citron-3374121
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 #2
prudloff commentedThe drupal_vimeo service seems to be vulnerable as well.
Comment #6
klelostec commentedComment #7
klelostec commentedComment #8
klelostec commentedComment #9
klelostec commented