-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(autocomplete): properly parse unsafe strings to prevent advanced XSS attacks #8368
Conversation
@ThomasBurleson LGTM, closes #8388 as well. |
f1f73cd
to
e25a01c
Compare
e25a01c
to
0b31a12
Compare
This doesn't work properly with html escaping. Also Is there a reason why you are using html escaping instead of regex escaping. I changed:
To:
Which makes it work well for me. Otherwise i can search for "amp" and all the ampersands come up in search results with the current solution. I suggest we add regex escape and then merge this into angular-material |
@jammed343 I cannot see that issue. The way we currently parse the unsafe string, seems to work as expected. It just depends on the native browser behavior, which makes sure that the displayed results and the search text match. Can you explain what issues you are experiencing? Did you run that PR already? |
@devversion this last screenshot is just to show that the data is fine normally |
@jammed343 Everything works for me as expected. And the tests are also passing. How did you pull / download this PR to run on your codebase?
Also the way this Regex parses the string is not valid. We want to retrieve the HTML encoded way, instead of the UTF-8 text.
|
@devversion I used the DevVersion:fix/parse-unsafe-regex branch which didn't work for me at first. then i modified the |
@jammed343 Hmm weird. The tests pass, the demos are working as expected. It may be an issue on the PR pulling. Not sure how you served your application with the new changes etc.
|
I added some console output to your original pull:
|
@devversion |
@ThomasBurleson @jammed343 I made some changes regarding the way we display the highlighted text. Those changes were necessary to support HTML entity identifiers and special characters inside of the highlight text. The current approach was very unstable and really dangerous for XSS attacks, since we are setting the |
@jammed343 - Thx for your persistence on improving this PR. 👍 |
@devversion - plz squash and (if needed) rebase. |
9173d08
to
17ccbda
Compare
…o html entities. * The highlight controller no longer sanitizes the term or content, because this would require complex libraries like `ngSanitize` * Also there is no need to sanitize those strings, because after this change we never insert them as HTML nodes anymore. * We decompose the content string into different tokens and then compose them together into different elements. This allows us to be 100% sure that we only insert trusted HTML code and no unsafe HTML code, which could include XSS attacks. * This approach also supports now HTML identifiers and special text characters in the highlight text and content. Fixes angular#8356
17ccbda
to
fee017e
Compare
ngSanitize
This allows us to be 100% sure that we only insert trusted HTML code and no unsafe HTML code, which could include XSS attacks.
Fixes #8356