-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
EnsureCSPDoesNotBlockStringCompilation: Why do we need to call "Get Trusted Type compliant string" when isTrusted is true? #49367
Comments
Assuming there is a situation in #49371 where isTrusted can become false because of a mismatch between the passed arg's data and the passed string, I'm actually not even sure if step 8 is correct:
So maybe when isTrusted=false what we want instead is to redo the work of A less strict approach, is to remove condition 8 so the algorithm can continue with the sourceString that has been "sanitized" by the default policy. |
It's explicitly designed so that if the default policy changes the string then it rejects for eval and Function. Loosening that would require ecma changes that would require going back to them to request. It's stricter specifically based on historical feedback from tc39. |
OK, agree it provides some stronger check but I still feel this is less intuitive than something like what And I still don't see why this is necessary when isTrusted=true. |
The tests added in https://phabricator.services.mozilla.com/D230369 now check step 8 i.e. throw iff the codeString is modified by "Get Trusted Type compliant string" (eval-function-constructor.html is using a null default policy, so algorithm is exiting at step 7). |
Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] #49371 [3] #49367 Differential Revision: https://phabricator.services.mozilla.com/D230369 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1934373 gecko-commit: cb03a787fe45e9a7bf5539008edbe0c0b79f1ca2 gecko-reviewers: smaug
…on. r=smaug Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] web-platform-tests/wpt#49371 [3] web-platform-tests/wpt#49367 Differential Revision: https://phabricator.services.mozilla.com/D230369
…on. r=smaug Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] web-platform-tests/wpt#49371 [3] web-platform-tests/wpt#49367 Differential Revision: https://phabricator.services.mozilla.com/D230369
…on. r=smaug Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] web-platform-tests/wpt#49371 [3] web-platform-tests/wpt#49367 Differential Revision: https://phabricator.services.mozilla.com/D230369 UltraBlame original commit: cb03a787fe45e9a7bf5539008edbe0c0b79f1ca2
…on. r=smaug Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] web-platform-tests/wpt#49371 [3] web-platform-tests/wpt#49367 Differential Revision: https://phabricator.services.mozilla.com/D230369 UltraBlame original commit: cb03a787fe45e9a7bf5539008edbe0c0b79f1ca2
…on. r=smaug Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] web-platform-tests/wpt#49371 [3] web-platform-tests/wpt#49367 Differential Revision: https://phabricator.services.mozilla.com/D230369 UltraBlame original commit: cb03a787fe45e9a7bf5539008edbe0c0b79f1ca2
Improve test coverage for [1], considering string checks for arguments that implement TrustedScript [2] and the rejection condition on whether "Get Trusted Type compliant string" modified the input [3]. [1] https://w3c.github.io/webappsec-csp/#can-compile-strings [2] #49371 [3] #49367 Differential Revision: https://phabricator.services.mozilla.com/D230369 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1934373 gecko-commit: cb03a787fe45e9a7bf5539008edbe0c0b79f1ca2 gecko-reviewers: smaug Co-authored-by: Frédéric Wang <[email protected]>
I just realized I opened this to the wrong repo. I meant to do it in CSP spec repo. |
Moved to w3c/webappsec-csp#698 |
cc @koto @lukewarlow
See https://w3c.github.io/webappsec-csp/#can-compile-strings
Steps 5-8 are as follows:
When isTrusted is false, then it makes sense to make sure codeString is not modified by "Get Trusted Type compliant string".
But when isTrusted is true, step 5) will just create a TrustedType with data set to codeString, step 6) will set set sourceString to codeString (https://www.w3.org/TR/trusted-types/#abstract-opdef-get-trusted-type-compliant-string exits early at step 1 and per https://www.w3.org/TR/trusted-types/#trusted-script stringified input is the same as returning the codeString data) ; step 7) will see no errors thrown and step 8) will see sourceString equal to codeString.
So why not just do If isTrusted is true then set sourceString to codeString, otherwise do the "Get Trusted Type compliant string" steps?
The text was updated successfully, but these errors were encountered: