Commit 7c42e2e
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 92db2ba commit 7c42e2e
File tree
18 files changed
+327
-154
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
+327
-154
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| |||
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: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
846 | | - | |
| 846 | + | |
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
| 857 | + | |
857 | 858 | | |
858 | 859 | | |
859 | 860 | | |
860 | 861 | | |
861 | 862 | | |
862 | 863 | | |
| 864 | + | |
863 | 865 | | |
864 | 866 | | |
865 | 867 | | |
866 | | - | |
| 868 | + | |
867 | 869 | | |
868 | 870 | | |
869 | 871 | | |
| |||
873 | 875 | | |
874 | 876 | | |
875 | 877 | | |
876 | | - | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
877 | 895 | | |
878 | 896 | | |
879 | 897 | | |
| |||
889 | 907 | | |
890 | 908 | | |
891 | 909 | | |
| 910 | + | |
892 | 911 | | |
893 | 912 | | |
894 | 913 | | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
895 | 919 | | |
896 | 920 | | |
897 | 921 | | |
| |||
Lines changed: 9 additions & 3 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 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
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 | |
|---|---|---|---|
| |||
9009 | 9009 | | |
9010 | 9010 | | |
9011 | 9011 | | |
| 9012 | + | |
| 9013 | + | |
| 9014 | + | |
| 9015 | + | |
| 9016 | + | |
| 9017 | + | |
| 9018 | + | |
| 9019 | + | |
| 9020 | + | |
| 9021 | + | |
| 9022 | + | |
| 9023 | + | |
| 9024 | + | |
| 9025 | + | |
| 9026 | + | |
| 9027 | + | |
| 9028 | + | |
| 9029 | + | |
| 9030 | + | |
| 9031 | + | |
| 9032 | + | |
| 9033 | + | |
| 9034 | + | |
| 9035 | + | |
| 9036 | + | |
| 9037 | + | |
| 9038 | + | |
9012 | 9039 | | |
9013 | 9040 | | |
9014 | 9041 | | |
| |||
9430 | 9457 | | |
9431 | 9458 | | |
9432 | 9459 | | |
9433 | | - | |
| 9460 | + | |
9434 | 9461 | | |
9435 | 9462 | | |
9436 | 9463 | | |
9437 | | - | |
| 9464 | + | |
9438 | 9465 | | |
9439 | 9466 | | |
9440 | 9467 | | |
| |||
9464 | 9491 | | |
9465 | 9492 | | |
9466 | 9493 | | |
9467 | | - | |
| 9494 | + | |
9468 | 9495 | | |
9469 | 9496 | | |
9470 | 9497 | | |
| |||
9523 | 9550 | | |
9524 | 9551 | | |
9525 | 9552 | | |
9526 | | - | |
| 9553 | + | |
9527 | 9554 | | |
9528 | 9555 | | |
9529 | 9556 | | |
9530 | | - | |
| 9557 | + | |
9531 | 9558 | | |
9532 | 9559 | | |
9533 | 9560 | | |
| |||
9553 | 9580 | | |
9554 | 9581 | | |
9555 | 9582 | | |
9556 | | - | |
| 9583 | + | |
9557 | 9584 | | |
9558 | 9585 | | |
9559 | 9586 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
573 | 577 | | |
574 | 578 | | |
575 | 579 | | |
| |||
585 | 589 | | |
586 | 590 | | |
587 | 591 | | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| |||
0 commit comments