Commit bad7fc1
committed
Merged PR 6983: MSRC 54120: XAMLReader.Load used by
[Bug 1092072](https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/1092072): MSRC 54120: XAMLReader.Load used by `GetFixedDocumentSequence` method which could lead to code execution [.Net Core 3.1] - Missing variant fix
## **Description**
Loose xaml can contain executable payload e.g. `ObjectDataProvider`. This XAML can be included as part of `XpsDocument`s in their `FixedDocumentSequence` or `FixedPage`.
In WPF, we were allowing `XpsDocument`s to be loaded freely via `XamlReader.Load`.
This exposes an attack vector - when a user downloads an XPS file from the internet for viewing, they could end up executing untrusted code.
The fix is to identify known dangerous `Type`s and limit them from being deserialized during XAML loading. In order to accomplish this, we previously added new non-public overloads to the `XamlReader.Load` method to enable the use of `RestrictiveXamlXmlReader`.`RestrictiveXamlXmlReader` restricts known dangerous `Type`s from being loaded while deserializing xaml.
One of these dangerous `Type`s is `System.Windows.ResourceDictionary`, which is a valid `Type` in XML schema. To allow this valid `Type` we added another non-public overload to the `XamlReader.Load` method which takes an additional parameter, safeTypes, a list of `Type`s which can be loaded safely. We also added a new constructor to the `RestrictiveXamlXmlReader` which takes an additional parameter of safeTypes which are marked as safe to load for this instance of the `RestrictiveXamlXmlReader`.
### **Customer Impact**
Customers would be protected from opening potentially-compromised XPS documents.
### **Regression**
No. This security issue was reported by an external party.
### **Risk - Low**
- This change only affects loading XPS documents.
- The change has been tested well internally.
- We ran regression tests to ensure nothing else is inadvertently broken.
- Validated against POC to ensure that the fix works as intended.GetFixedDocumentSequence method which could lead to code execution [.Net Core 3.1] - Missing variant fix1 parent 03203cc commit bad7fc1
File tree
3 files changed
+55
-13
lines changed- src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows
- Documents
- Markup
3 files changed
+55
-13
lines changedLines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | | - | |
68 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
64 | 78 | | |
65 | 79 | | |
66 | 80 | | |
| |||
Lines changed: 30 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
751 | 775 | | |
752 | 776 | | |
753 | 777 | | |
| |||
805 | 829 | | |
806 | 830 | | |
807 | 831 | | |
808 | | - | |
| 832 | + | |
809 | 833 | | |
810 | 834 | | |
811 | 835 | | |
| |||
0 commit comments