-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[Desktop] Avoid relying on innerHTML for Brave Rewards & Welcome pages #11642
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
Comments
good call, we shouldn't be using innerHTML anyway. (it's mentioned in our security review guidelines) |
@mariospr how do i revert this patch for a build? sorry i've not had to do this before. |
Apologies, I think I might have poorly explained the problem in the description 🤔 There is no patch to revert on any current build, nor even on a branch right now... the problem only affected the WIP branch So, when I said that the problem reproduces "always for Brave 1.15.37 or newer (Chromium: 87.0.4250.0), but only with the patch reverted", it was just a way for me to show where the problem was before it got worked around for the incoming cr87-based release, not that the problem is still reproducible in there. But, as said, this is a workaround and the true fix would be to avoid relying on innerHTML, which is what this issue is actually for. Hope that this clarifies things, but please feel free to ask more questions if not! 🙂 |
For localization of strings that may contain markup (such as links) when displayed, we should use the pattern described here. |
@mariospr ah ok, thanks for clarifying. |
Verification passed on
Verification completed using
Verified test plan from brave/brave-core#6669
Encountered #11908 when attempting to confirm unsupported region message. Verification passed on
|
Removed |
Description
For Chromium 87, we needed to push a patch named "Disable Trusted Types mitigation on Brave's Welcome & Rewards pages" that disables the Content Security Policy for Trusted Types in Brave's Welcome and Rewards WebUI pages, since they rely on the ability to assign untrusted text to the
innerHTML
element to deal with translations and error messages (you can search fordangerouslySetInnerHTML
in*.tsx
files to find where exactly this is a problem).This is consistent with what upstream Chromium does for pages that don't support Trusted Types yet (see CL 2234238), but it would be good if Brave's WebUI pages could eventually migrate from this model, which would need some refactor of the current JS code, which heavily relies on
innerHTML
for translations.Chromium change:
Steps to Reproduce
Actual result:
The page doesn't load and there's an error on the console saying "This document requires 'TrustedHTML' assignment."
Expected result:
The page should work fine, no errors on the console.
Reproduces how often:
Always, assuming the patch mentioned in the description is reverted
Brave version (brave://version info)
Brave 1.15.37 or newer (Chromium: 87.0.4250.0 (Developer Build) (64-bit)), but only with the patch reverted.
QA test steps
see test plan in brave/brave-core#6669
The text was updated successfully, but these errors were encountered: