Skip to content

Commit c42fcf1

Browse files
authored
Merge pull request #3020 from arpitmathur/dev/arpit/release_may
Fixing Microsoft Security Advisory CVE-2020-0605 : .NET Core Remote Code Execution Vulnerability- Variant (.Net Core 3.1)
2 parents 88ef543 + bad7fc1 commit c42fcf1

File tree

5 files changed

+71
-15
lines changed

5 files changed

+71
-15
lines changed

NuGet.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
<add key="arcade" value="https://dotnetfeed.blob.core.windows.net/dotnet-tools-internal/index.json" />
1212
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
1313
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
14-
<add key="dotnet3" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3/nuget/v3/index.json" />
15-
<add key="dotnet3-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3-transport/nuget/v3/index.json" />
1614
<add key="dotnet3.1" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1/nuget/v3/index.json" />
1715
<add key="dotnet3.1-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1-transport/nuget/v3/index.json" />
1816
<add key="dotnet-coreclr" value="https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json" />

eng/pipeline.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jobs:
6767
value: ''
6868
- name: _HelixCreator
6969
value: ${{ parameters.repoName }}
70+
- name: _InternalRuntimeDownloadArgs
71+
value: ''
7072

7173

7274
# Override some values if we're building internally
@@ -109,6 +111,10 @@ jobs:
109111
value: '' #if _HelixToken is set, Creator must be empty
110112
- name: _TestHelixAgentPool
111113
value: 'Windows.10.Amd64.ClientRS5' # Preferred: 'Windows.10.Amd64%3bWindows.7.Amd64%3bWindows.10.Amd64.ClientRS5'
114+
- group: DotNet-MSRC-Storage
115+
- name: _InternalRuntimeDownloadArgs
116+
value: /p:DotNetRuntimeSourceFeed=https://dotnetclimsrc.blob.core.windows.net/dotnet
117+
/p:DotNetRuntimeSourceFeedKey=$(dotnetclimsrc-read-sas-token-base64)
112118

113119
strategy:
114120
matrix:
@@ -138,6 +144,15 @@ jobs:
138144
- powershell: eng\pre-build.ps1
139145
displayName: Pre-Build - Set VSO Variables
140146

147+
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
148+
- task: PowerShell@2
149+
displayName: Setup Private Feeds Credentials
150+
inputs:
151+
filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1
152+
arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token
153+
env:
154+
Token: $(dn-bot-dnceng-artifact-feeds-rw)
155+
141156
# Use utility script to run script command dependent on agent OS.
142157
- script: eng\common\cibuild.cmd
143158
-configuration $(_BuildConfig)
@@ -146,6 +161,7 @@ jobs:
146161
$(_SignArgs)
147162
$(_OfficialBuildIdArgs)
148163
$(_PlatformArgs)
164+
$(_InternalRuntimeDownloadArgs)
149165
displayName: Windows Build / Publish
150166
# This condition should be kept in sync with the condition for 'Run DRTs' step
151167
# When building on a regular pipeline (!_HelixPipeline), build as usual

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/XpsS0ValidatingLoader.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ internal void Validate(Stream stream, Uri parentUri, ParserContext pc, ContentTy
5959
/// <returns></returns>
6060
private object Load(Stream stream, Uri parentUri, ParserContext pc, ContentType mimeType, string rootElement)
6161
{
62-
object obj = null;
62+
object obj = null;
63+
64+
List<Type> safeTypes = new List<Type> { typeof(System.Windows.ResourceDictionary) };
6365

6466
if (!DocumentMode)
6567
{ // Loose XAML, just check against schema, don't check content type
6668
if (rootElement==null)
67-
{
68-
obj = XamlReader.Load(stream, pc);
69+
{
70+
XmlReader reader = XmlReader.Create(stream, null, pc);
71+
obj = XamlReader.Load(reader, pc, XamlParseMode.Synchronous, true, safeTypes);
72+
stream.Close();
6973
}
7074
}
7175
else
@@ -148,10 +152,10 @@ private object Load(Stream stream, Uri parentUri, ParserContext pc, ContentType
148152
;
149153
}
150154
else
151-
{
152-
obj = XamlReader.Load(xpsSchemaValidator.XmlReader,
153-
pc,
154-
XamlParseMode.Synchronous);
155+
{
156+
obj = XamlReader.Load(xpsSchemaValidator.XmlReader,
157+
pc,
158+
XamlParseMode.Synchronous, true, safeTypes);
155159
}
156160
_validResources.Pop();
157161
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/RestrictiveXamlXmlReader.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ static RestrictiveXamlXmlReader()
6161
/// </summary>
6262
public RestrictiveXamlXmlReader(XmlReader xmlReader, XamlSchemaContext schemaContext, XamlXmlReaderSettings settings) : base(xmlReader, schemaContext, settings)
6363
{
64+
}
65+
66+
/// <summary>
67+
/// Builds the restricted set based on RestrictedTypes that have already been loaded but adds the list of Types passed in in safeTypes to the instance of _safeTypesSet
68+
/// </summary>
69+
internal RestrictiveXamlXmlReader(XmlReader xmlReader, XamlSchemaContext schemaContext, XamlXmlReaderSettings settings, List<Type> safeTypes) : base(xmlReader, schemaContext, settings)
70+
{
71+
if (safeTypes != null)
72+
{
73+
foreach (Type safeType in safeTypes)
74+
{
75+
_safeTypesSet.Add(safeType);
76+
}
77+
}
6478
}
6579

6680
/// <summary>

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlReader.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
using System.IO.Packaging;
1414
using System.Windows;
1515
using System.ComponentModel;
16-
using System.Collections;
16+
using System.Collections;
17+
using System.Collections.Generic;
1718
using System.Diagnostics;
1819
using System.Reflection;
1920

@@ -744,10 +745,33 @@ internal static object Load(
744745
/// RestrictiveXamlXmlReader to restrict instantiation of potentially dangerous types</param>
745746
/// <returns>object root generated after xml parsed</returns>
746747
internal static object Load(
747-
XmlReader reader,
748-
ParserContext parserContext,
749-
XamlParseMode parseMode,
750-
bool useRestrictiveXamlReader)
748+
XmlReader reader,
749+
ParserContext parserContext,
750+
XamlParseMode parseMode,
751+
bool useRestrictiveXamlReader)
752+
{
753+
return Load(reader, parserContext, parseMode, useRestrictiveXamlReader, null);
754+
}
755+
756+
/// <summary>
757+
/// Reads XAML from the passed stream, building an object tree and returning the
758+
/// root of that tree. Wrap a CompatibilityReader with another XmlReader that
759+
/// uses the passed reader settings to allow validation of xaml.
760+
/// </summary>
761+
/// <param name="reader">XmlReader to use. This is NOT wrapped by any
762+
/// other reader</param>
763+
/// <param name="context">Optional parser context. May be null </param>
764+
/// <param name="parseMode">Sets synchronous or asynchronous parsing</param>
765+
/// <param name="useRestrictiveXamlReader">Whether or not this method should use
766+
/// RestrictiveXamlXmlReader to restrict instantiation of potentially dangerous types</param>
767+
/// <param name="safeTypes">List of known safe Types to be allowed through the RestrictiveXamlXmlReader</param>
768+
/// <returns>object root generated after xml parsed</returns>
769+
internal static object Load(
770+
XmlReader reader,
771+
ParserContext parserContext,
772+
XamlParseMode parseMode,
773+
bool useRestrictiveXamlReader,
774+
List<Type> safeTypes)
751775
{
752776
if (parseMode == XamlParseMode.Uninitialized ||
753777
parseMode == XamlParseMode.Asynchronous)
@@ -805,7 +829,7 @@ internal static object Load(
805829

806830
XamlSchemaContext schemaContext = parserContext.XamlTypeMapper != null ?
807831
parserContext.XamlTypeMapper.SchemaContext : GetWpfSchemaContext();
808-
System.Xaml.XamlXmlReader xamlXmlReader = (useRestrictiveXamlReader) ? new RestrictiveXamlXmlReader(reader, schemaContext, settings):
832+
System.Xaml.XamlXmlReader xamlXmlReader = (useRestrictiveXamlReader) ? new RestrictiveXamlXmlReader(reader, schemaContext, settings, safeTypes) :
809833
new System.Xaml.XamlXmlReader(reader, schemaContext, settings);
810834
root = Load(xamlXmlReader, parserContext);
811835
reader.Close();

0 commit comments

Comments
 (0)