8000 Manipulation: Make jQuery.htmlPrefilter an identity function by mgol · Pull Request #4642 · jquery/jquery · GitHub
[go: up one dir, main page]

Skip to content

Manipulation: Make jQuery.htmlPrefilter an identity function #4642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2020

Conversation

mgol
Copy link
Member
@mgol mgol commented Mar 14, 2020

Summary

Make jQuery.htmlPrefilter an identity function; fix tests.

This is a security fix for CVE-2020-11022.

Checklist

@mgol mgol added Needs review Tests Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labels Mar 14, 2020
@mgol mgol added this to the 3.5.0 milestone Mar 14, 2020
@mgol mgol self-assigned this Mar 14, 2020
Copy link
Member
@timmywil timmywil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mgol mgol force-pushed the no-xhtml-shortcuts branch from 6ad1aed to db0cfbe Compare March 16, 2020 17:15
@mgol mgol changed the title Tests: Make tests pass with jQuery.htmlPrefilter being an identity function Manipulation: Make jQuery.htmlPrefilter an identity function Mar 16, 2020
@mgol mgol added Manipulation and removed Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. Needs review Tests labels Mar 16, 2020
@mgol mgol merged commit 90fed4b into jquery:master Mar 16, 2020
@mgol mgol deleted the no-xhtml-shortcuts branch March 16, 2020 20:49
mgol added a commit that referenced this pull request Mar 16, 2020
@mgol
Copy link
Member Author
mgol commented Mar 16, 2020

Landed on master in 90fed4b & on 3.x-stable in 1d61fd9.

@Krinkle
Copy link
Member
Krinkle commented May 7, 2020

A visual example of CVE-2020-11022 (based on the tests from #4685).

CVE-2020-11022

mgol added a commit to mgol/jquery that referenced this pull request Jun 5, 2020
The issue about selectors with '#' being broken is old and no longer frequently
reported so this commit removes it from the list. On the other hand, we're now
getting lots of reports about the security fix in jQuery 3.5.0 that was also
a breaking change: jquerygh-4642. This one is now mentioned in the list.

Ref jquerygh-4642
mgol added a commit to mgol/jquery that referenced this pull request Jun 5, 2020
The issue about selectors with '#' being broken is old and no longer frequently
reported so this commit removes it from the list. On the other hand, we're now
getting lots of reports about the security fix in jQuery 3.5.0 that was also
a breaking change: jquerygh-4642. This one is now mentioned in the list.

Ref jquerygh-4642
mgol added a commit that referenced this pull request Jun 8, 2020
The issue about selectors with '#' being broken is old and no longer
frequently reported so this commit removes it from the list. On the other
hand, we're now getting lots of reports about the security fix in jQuery 3.5.0
that was also a breaking change: gh-4642. This one is now mentioned in the
list.

Closes gh-4728
Ref gh-4642
serg-cymbaluk added a commit to serg-cymbaluk/freeipa that referenced this pull request Sep 21, 2020
The commit includes the following jQuery patches:
- Manipulation: Make jQuery.htmlPrefilter an identity function
  (jquery/jquery#4642)
- Manipulation: Skip the select wrapper for <option> outside of IE 9
  (jquery/jquery#4647)

In addition there is included a script that helps to patch and build
the new version of jQuery:

  $ install/ui/util/make-jquery.js 3.4.1

Ticket: https://pagure.io/freeipa/issue/8507

Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
serg-cymbaluk added a commit to serg-cymbaluk/freeipa that referenced this pull request Sep 23, 2020
The commit includes the following jQuery patches:
- Manipulation: Make jQuery.htmlPrefilter an identity function
  (jquery/jquery#4642)
- Manipulation: Skip the select wrapper for <option> outside of IE 9
  (jquery/jquery#4647)

In addition there is included a script that helps to patch and build
the new version of jQuery:

  $ install/ui/util/make-jquery.js 3.4.1

Ticket: https://pagure.io/freeipa/issue/8507

Signed-off-by: Serhii Tsymbaliuk <stsymbal@redhat.com>
mgol added a commit to mgol/jquery that referenced this pull request Sep 13, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
jquerygh-4642 and jquerygh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes jquerygh-4409
Ref jquerygh-4642
Ref jquerygh-4724
mgol added a commit to mgol/jquery that referenced this pull request Sep 14, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
jquerygh-4642 and jquerygh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes jquerygh-4409
Ref jquerygh-4642
Ref jquerygh-4724
mgol added a commit to mgol/jquery that referenced this pull request Sep 17, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
jquerygh-4642 and jquerygh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes jquerygh-4409
Ref jquerygh-4642
Ref jquerygh-4724
mgol added a commit to mgol/jquery that referenced this pull request Sep 23, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
jquerygh-4642 and jquerygh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes jquerygh-4409
Ref jquerygh-4642
Ref jquerygh-4724
mgol added a commit to mgol/jquery that referenced this pull request Sep 29, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
jquerygh-4642 and jquerygh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes jquerygh-4409
Ref jquerygh-4642
Ref jquerygh-4724
mgol added a commit to mgol/jquery that referenced this pull request Sep 29, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
jquerygh-4642 and jquerygh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes jquerygh-4409
Ref jquerygh-4642
Ref jquerygh-4724
mgol added a commit that referenced this pull request Sep 30, 2021
This ensures HTML wrapped in TrustedHTML can be used as an input to jQuery
manipulation methods in a way that doesn't violate the
`require-trusted-types-for` Content Security Policy directive.
This commit builds on previous work needed for trusted types support, including
gh-4642 and gh-4724.

One restriction is that while any TrustedHTML wrapper should work as input
for jQuery methods like `.html()` or `.append()`, for passing directly to the
`jQuery` factory the string must start with `<` and end with `>`; no trailing
or leading whitespaces are allowed. This is necessary as we cannot parse out
a part of the input for further construction; that would violate the CSP rule -
and that's what's done to HTML input not matching these constraints.

No trusted types API is used explicitly in source; the majority of the work is
ensuring we don't pass the input converted to string to APIs that would
eventually assign it to `innerHTML`. This extra cautiousness is caused by the
API being Blink-only, at least for now.

The ban on passing strings to `innerHTML` means support tests relying on such
assignments are impossible. We don't currently have such tests on the `main`
branch but we used to have many of them in the 3.x & older lines. If there's
a need to re-add such a test, we'll need an escape hatch to skip them for apps
needing CSP-enforced TrustedHTML.

See https://web.dev/trusted-types/ for more information about TrustedHTML.

Fixes gh-4409
Closes gh-4927
Ref gh-4642
Ref gh-4724
tamcy pushed a commit to tamcy/jquery that referenced this pull request Mar 17, 2022
Closes jquerygh-4642

(cherry picked from 90fed4b)

# Conflicts:
#	src/manipulation.js
#	test/data/testinit.js
#	test/unit/ajax.js
#	test/unit/attributes.js
#	test/unit/basic.js
#	test/unit/core.js
#	test/unit/css.js
#	test/unit/data.js
#	test/unit/deprecated.js
#	test/unit/dimensions.js
#	test/unit/effects.js
#	test/unit/event.js
#	test/unit/manipulation.js
#	test/unit/offset.js
#	test/unit/traversing.js
msablic added a commit to msablic/jquery that referenced this pull request Sep 29, 2022
rickypowell pushed a commit to draios/jquery that referenced this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants
0