Commit d1ca8ae
fix(compiler): prevent XSS via SVG animation
This commit implements a security fix to prevent XSS vulnerabilities where SVG animation elements (`<animate>`, `<set>`, etc.) could be used to modify the `href` or `xlink:href` attributes of other elements to `javascript:` URLs.
The fix introduces a runtime validation step:
- A new [ɵɵValidateAttribute](cci:1://file:///usr/local/google/home/alanagius/git/angular/packages/core/src/sanitization/sanitization.ts:276:0-288:1) instruction is used when `attributeName` is bound on SVG animation elements.
- If executed, a `RuntimeError` is thrown, preventing the binding.
- The compiler now identifies `attributeName` on SVG animation elements as security-sensitive and injects this validation.
Additionally, the DOM security schema has been updated to include a comprehensive list of MathML and SVG elements that accept `href` or `xlink:href` attributes, ensuring they are correctly treated as `SecurityContext.URL` and sanitized. This prevents malicious URLs from being bound to these attributes.
http://b/463880509attributeName and MathML/SVG URLs1 parent 136e923 commit d1ca8ae
File tree
18 files changed
+325
-152
lines changed- goldens/public-api/core
- packages
- compiler-cli/test
- compliance/test_cases
- r3_compiler_compliance/elements
- r3_view_compiler_bindings
- host_bindings
- property_bindings
- ngtsc
- compiler
- src
- render3
- schema
- template/pipeline/src/phases
- test
- core
- src
- render3/jit
- sanitization
- test/acceptance
18 files changed
+325
-152
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
884 | | - | |
| 884 | + | |
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
| |||
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
| 895 | + | |
895 | 896 | | |
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
900 | 901 | | |
| 902 | + | |
901 | 903 | | |
902 | 904 | | |
903 | 905 | | |
| |||
915 | 917 | | |
916 | 918 | | |
917 | 919 | | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
918 | 936 | | |
919 | 937 | | |
920 | 938 | | |
| |||
927 | 945 | | |
928 | 946 | | |
929 | 947 | | |
| 948 | + | |
930 | 949 | | |
931 | 950 | | |
932 | 951 | | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
933 | 957 | | |
934 | 958 | | |
935 | 959 | | |
| |||
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9261 | 9261 | | |
9262 | 9262 | | |
9263 | 9263 | | |
| 9264 | + | |
| 9265 | + | |
| 9266 | + | |
| 9267 | + | |
| 9268 | + | |
| 9269 | + | |
| 9270 | + | |
| 9271 | + | |
| 9272 | + | |
| 9273 | + | |
| 9274 | + | |
| 9275 | + | |
| 9276 | + | |
| 9277 | + | |
| 9278 | + | |
| 9279 | + | |
| 9280 | + | |
| 9281 | + | |
| 9282 | + | |
| 9283 | + | |
| 9284 | + | |
| 9285 | + | |
| 9286 | + | |
| 9287 | + | |
| 9288 | + | |
| 9289 | + | |
| 9290 | + | |
9264 | 9291 | | |
9265 | 9292 | | |
9266 | 9293 | | |
| |||
9682 | 9709 | | |
9683 | 9710 | | |
9684 | 9711 | | |
9685 | | - | |
| 9712 | + | |
9686 | 9713 | | |
9687 | 9714 | | |
9688 | 9715 | | |
9689 | | - | |
| 9716 | + | |
9690 | 9717 | | |
9691 | 9718 | | |
9692 | 9719 | | |
| |||
9716 | 9743 | | |
9717 | 9744 | | |
9718 | 9745 | | |
9719 | | - | |
| 9746 | + | |
9720 | 9747 | | |
9721 | 9748 | | |
9722 | 9749 | | |
| |||
9775 | 9802 | | |
9776 | 9803 | | |
9777 | 9804 | | |
9778 | | - | |
| 9805 | + | |
9779 | 9806 | | |
9780 | 9807 | | |
9781 | 9808 | | |
9782 | | - | |
| 9809 | + | |
9783 | 9810 | | |
9784 | 9811 | | |
9785 | 9812 | | |
| |||
9805 | 9832 | | |
9806 | 9833 | | |
9807 | 9834 | | |
9808 | | - | |
| 9835 | + | |
9809 | 9836 | | |
9810 | 9837 | | |
9811 | 9838 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
460 | 464 | | |
461 | 465 | | |
462 | 466 | | |
| |||
472 | 476 | | |
473 | 477 | | |
474 | 478 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
0 commit comments