diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs index c30467978a08cd1db39c3b8bc532bfe6cb8dfcfa..49aba05cc78a33dc3d2dabc94e86048f2b55191f 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SecurityHelper.cs @@ -353,60 +353,24 @@ internal static bool IsFullTrustCaller() /// path. /// /// - /// This function exists solely as a an optimazation for the debugger scenario + /// In .NET Core 3.0+, always return true. /// - /// - /// Critical: This code extracts the permission set associated with an appdomain by elevating - /// TreatAsSafe: The information is not exposed - /// [SecuritySafeCritical] internal static bool CallerHasPermissionWithAppDomainOptimization(params IPermission[] permissionsToCheck) { -#if NETFX - // in case of passing null return true - if (permissionsToCheck == null) - return true; - PermissionSet psToCheck = new PermissionSet(PermissionState.None); - for ( int i = 0 ; i < permissionsToCheck.Length ; i++ ) - { - psToCheck.AddPermission(permissionsToCheck[i]); - } - PermissionSet permissionSetAppDomain = AppDomain.CurrentDomain.PermissionSet; - if (psToCheck.IsSubsetOf(permissionSetAppDomain)) - { - return true; - } - return false; -#else return true; -#endif } /// Enables an efficient check for a specific permisison in the AppDomain's permission grant /// without having to catch a SecurityException in the case the permission is not granted. /// - /// - /// Caveat: This is not a generally valid substitute for doing a full Demand. The main cases not - /// covered are: - /// 1) call from PT AppDomain into full-trust one; - /// 2) captured PT callstack (via ExecutionContext) from another thread or context. Our Dispatcher - /// does this. - /// - /// Critical: Accesses the Critical AppDomain.PermissionSet, which might contain sensitive information - /// such as file paths. - /// Safe: Does not expose the permission object to the caller. - /// + /// + /// In .NET Core 3.0+, always return true + /// [SecuritySafeCritical] internal static bool AppDomainHasPermission(IPermission permissionToCheck) { -#if NETFX - Invariant.Assert(permissionToCheck != null); - PermissionSet psToCheck = new PermissionSet(PermissionState.None); - psToCheck.AddPermission(permissionToCheck); - return psToCheck.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet); -#else return true; -#endif } /// @@ -560,11 +524,8 @@ internal static void DemandFilePathDiscoveryWriteRead() [SecurityCritical] internal static PermissionSet ExtractAppDomainPermissionSetMinusSiteOfOrigin() { -#if NETFX - PermissionSet permissionSetAppDomain = AppDomain.CurrentDomain.PermissionSet; -#else + // In .NET Core 3.0+, always use PermissionState.Unrestricted PermissionSet permissionSetAppDomain = new PermissionSet(PermissionState.Unrestricted); -#endif // Ensure we remove the FileIO read permission to site of origin. // We choose to use unrestricted here because it does not matter