Skip to content

Commit

Permalink
Remove ExtractAppDomainPermissionSetMinusSiteOfOrigin and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vatsan-madhavan committed Jun 24, 2019
1 parent e065272 commit 49f8134
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 416 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
<Compile Include="MS\Internal\AnimatedTypeHelpers.cs" />
<Compile Include="MS\Internal\CheckedPointers.cs" />
<Compile Include="MS\Internal\Classification.cs" />
<Compile Include="MS\Internal\ConstrainedDataObject.cs" />
<Compile Include="MS\Internal\CoreAppContextSwitches.cs" />
<Compile Include="MS\Internal\CustomCategoryAttribute.cs" />
<Compile Include="MS\Internal\DeferredElementTreeState.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,46 +651,6 @@ private static bool IsDynamicCodePolicyEnabled()
return isEnabled;
}

private static bool IsDataObjectFromLessPriviligedApplicationDomain(IDataObject dataObjectToApply)
{
bool retVal = false;
object applicationTrust = null;
// Extract the permission set in case of xaml cut and paste
// extract permission set if it exists if not data came from full trust app and we do not care
bool isApplicationTrustFormatPresent = false;
isApplicationTrustFormatPresent = dataObjectToApply.GetDataPresent(DataFormats.ApplicationTrust, /*autoConvert:*/false);
if (isApplicationTrustFormatPresent)
{
applicationTrust = dataObjectToApply.GetData(DataFormats.ApplicationTrust, /*autoConvert:*/false);
}

if (applicationTrust != null)
{
string applicationTrustText = null;
// convert to string
applicationTrustText = applicationTrust.ToString();


// Convert string to permission set for getting permission set of source
PermissionSet permissionSetSource;
try
{
SecurityElement securityElement = SecurityElement.FromString(applicationTrustText);
permissionSetSource = new System.Security.PermissionSet(PermissionState.None);
permissionSetSource.FromXml(securityElement);
}
catch(XmlSyntaxException)
{
// This is the condition where we have Malformed XML in the clipboard for application trust
// here we will fail silently since we do not want to break arbitrary applications
// but since we cannot establish the validity of the application trust content we will fall back to
// whatever is more secure
return true;
}
}
return retVal;
}

private static IDataObject GetDataObjectInternal()
{
IDataObject dataObject;
Expand Down Expand Up @@ -734,23 +694,7 @@ private static IDataObject GetDataObjectInternal()
{
dataObject = null;
}
// We make this check outside of the loop independant of whether the data is ole data object or IDataObject
// Although one is unable to create an OleDataObject in partial trust we still need to ensure that if he did
// we strip the formats we care about by wrapping in ConstrainedDataObject
if (dataObject != null)
{
// this is the case we are concerend about where content comes from partial trust into full trust
// in the case where data contained is in one of the two formats: XAML or ApplicationTrust we return a wrapper
// that blocks access to these
if (IsDataObjectFromLessPriviligedApplicationDomain(dataObject) &&
(dataObject.GetDataPresent(DataFormats.Xaml, /*autoConvert:*/false) ||
dataObject.GetDataPresent(DataFormats.ApplicationTrust, /*autoConvert:*/false)))
{
// in this case we set the data object to be a wrapper data object that blocks off
// xaml or application trust formats if they exist
dataObject = new ConstrainedDataObject(dataObject);
}
}

return dataObject;
}

Expand Down
Loading

0 comments on commit 49f8134

Please sign in to comment.