Skip to content

Trusted Type Knockout#2580

Merged
mbest merged 5 commits intoknockout:masterfrom
shhnjk:master
Mar 8, 2026
Merged

Trusted Type Knockout#2580
mbest merged 5 commits intoknockout:masterfrom
shhnjk:master

Conversation

@shhnjk
Copy link
Copy Markdown

@shhnjk shhnjk commented Oct 8, 2021

This change adds Trusted Types support to Knockout.

All the changes are behind typeof trustedTypes !== 'undefined', so this change should only affect Chromium users (where Trusted Types is supported). Unless developers who uses Knockout wants to enforce Trusted Types, this change won't affect anyone.

Note that this only prevents DOM-based XSS, so stored and reflected XSS are still possible.

Fixes #2579.

@mbest mbest added this to the 3.5.2 milestone Mar 8, 2026
mbest added 2 commits March 8, 2026 05:24
Create a TrustedTypes policy ('knockout') with createHTML and createScript
to allow Knockout to work under CSP require-trusted-types-for enforcement.

Use eval instead of new Function for binding expressions since Chrome
doesn't accept TrustedScript in the Function constructor.

Add e2e tests that verify both production and debug builds under
Trusted Types CSP enforcement.
@mbest mbest merged commit 7e39cf6 into knockout:master Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Trusted Types

2 participants