Background information

This was originally reported as a private security issue, but has been approved for handling in the public queue by the Drupal Security Team.

Problem/Motivation

The resetForm() method provided by jquery-form is vulnerable to XSS if it is used on a label element and an attacker can control the value of the for attribute of this element.

It passes the value of this attribute to $() without making sure it does not contain HTML:

			case 'label':
				var forEl = $(el.attr('for'));

Steps to reproduce

{{ attach_library('core/internal.jquery.form') }}
<label id="label" for="&lt;img src=x onerror=alert()&gt;">Label</label>
<script>
  window.addEventListener('load', function() {
    jQuery('#label').resetForm();
  });
</script>

Proposed resolution

Drupal never uses resetForm() and the library is internal (#3293156: core/jquery.form library deprecated) so it should not be used by contrib.
The solution could be to remove resetForm() entirely since we don't use it.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3607794

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

prudloff created an issue. See original summary.

prudloff’s picture

Status: Active » Needs review

Do we need a CR if the library is marked as internal?

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

I don't think so. As you mentioned no contrib should be using it, if they are I'd assume they know they are taking the risk.

catch’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs change record

In this case I think we do need a change record - while the entire library is internal, it's loaded on every form so the method is available to use, and we'll want to backport this to patch releases probably.

smustgrave’s picture

Status: Needs review » Needs work

For the CR