-
Notifications
You must be signed in to change notification settings - Fork 26.2k
feat(core): add missing ARIA attributes to html sanitizer #29685
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
Conversation
1f4e2be
to
33877c6
Compare
Hi, the This seems to be the problem:
Is there anything I can do to fix this? Edit: I tried to restart the CI job, but I don't seem to have permission. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjamet do you have any security concerns about any of these attributes? thanks!
@MartinMa the tests are failing because you added too much "weight" to the framework which has a negative impact on the payload size. We'll need to discuss whether this is just something we have to swallow (and update the limit in the test), or if there are other measures that could allow these attributes while not increase the size. One to consider is allowing any "aria-" prefixed attribute without listing them specifically (this seems like a bad idea to me but @rjamet should weigh in on that option as well). |
@MartinMa you brought up an interesting issue that has competing security, accessibility, and performance requirements. It's going to be interesting to see how we resolve it. 😄 |
No concern for security: I think the worse effect you'd get is something phishing-like, which is expected with a sanitizer, or confusing navigation/interactions (especially aria-activedescendant), which is also reasonable to expect from adversarial sanitized HTML. |
@IgorMinar Interesting considerations. A regex solution could be more lightweight. I think you'd probably have to change this line: if (!VALID_ATTRS.hasOwnProperty(lower)) { to this: if (!(VALID_ATTRS.hasOwnProperty(lower) || ARIA_REGEX.test(lower))) { while const ARIA_REGEX = /^aria-[a-z]*$/; // 1
const ARIA_REGEX = /^aria-[a-z]+$/; // 2
const ARIA_REGEX = /^aria-[a-z]{4,16}$/; // 3
const ARIA_REGEX = /^aria-(a(ctivedescendant|tomic|utocomplete)|busy|c(hecked|o(l(count|index|span)|ntrols)|urrent)|d(e(scribedby|tails)|isabled|ropeffect)|e(rrormessage|xpanded)|flowto|grabbed|h(aspopup|idden)|invalid|keyshortcuts|l(abel(|ledby)|evel|ive)|m(odal|ulti(line|selectable))|o(rientation|wns)|p(laceholder|osinset|ressed)|r(e(adonly|levant|quired)|oledescription|ow(count|index|span))|s(e(lected|tsize)|ort)|value(max|min|now|text))$/; // 4 I think something like 4 is a nightmare. 3 would cover the longest keyword Personally however, I am a fan of extending If i understand correctly. Security is no concern with both approaches (strict list vs. relaxed regex) Another question: Does the metric "uncompressed bundle size" count comments in? |
@MartinMa ... This PR is really close to getting merged. Do you think you can figure out what is going wrong with the failing test in CI? It might be that it needs a rebase, I'm not sure, I didn't dig into it. 👍 Good luck |
33877c6
to
c10ca12
Compare
@benlesh I rebased the commit on top of master but the integration test is still failing because of:
We were discussing if the payload limits in this tests should be adjusted accordingly ... (see the earlier comments). Please tell me if there is anything else I can do. |
Paging @IgorMinar for review... Should he update the payload size? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright.. let's update the payload size limit and get this merged. We will need to save some code somewhere to make up for the size increase, but we shouldn't be sacrificing accessibility to keep Angular small.
Let's keep the code as is for readability.
perf musings: We might want to try to improve upon it in a separate PR by constructing the array and adding the duplicated "aria-" prefix to all the strings via a map
(e.g. 'multiselectable,orientation,owns'.split(',').map(s =>
aria-${s})
). I'm not even sure if that would be a clear perf win because of the extra eval cost, but since we are evaling these strings anyway it seems plausible that it would be faster - we'd need to test on https://www.webpagetest.org/easy to verify but doing so accurately will be hard. (keep in mind that even though gzip/brotli optimizes away the duplication the js parser still has to process the uncompressed payload so that's the part we are trying to optimize and it's not clear whether we should trade of js parser time or js eval time here.
Thanks @rjamet for the security review.
c10ca12
to
09b24e4
Compare
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
) Allow ARIA attributes from the WAI-ARIA 1.1 spec which were stripped by the htmlSanitizer. Closes angular#26815 PR Close angular#29685
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Allow ARIA attributes from the WAI-ARIA 1.1 spec, which were stripped by the
htmlSanitizer
.Closes #26815
PR Checklist
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Aria attributes like
aria-label
are being stripped by the html sanitizer as unsafe html.Issue Number: #26815
What is the new behavior?
aria-*
attributes are treated as safe html and are not being stripped by the html sanitizer (for example when used within[innerHTML]
).Does this PR introduce a breaking change?