You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SecurityManager.GetStandardSandbox returns null instead of a PermissionsSet that equates to full trust.
Other methods like XXXPermission.IsUnrestricted return false instead of true.
This is causing failures on .NET Core for code that would work on .NET Framework.
I think our intent was to behave as if we were always in full trust.
That was one principle. Another principle was to try to avoid silently introducing security bugs if the code depends on CAS. That's why some of the stub methods throw instead of just being a no-op. For example, consider this code that somebody might have written using GetStandardSandbox:
string url = "https://www.malware.com";
Evidence e = new Evidence();
e.AddAssemblyEvidence(new Url(url));
PermissionSet ps = SecurityManager.GetStandardSandbox(e);
if (ps.IsUnrestricted()) // This will return false in .NET Framework, even under full trust
{
... download and run code from url ...
}
If you make GetStandardSandbox to return unrestricted permission set, you will introduce security bug in this code.
Honestly that's why I'd prefer all these methods to throw NSE. CAS has been broken for years and we don't want to encourage people to bring existing CAS-related code forward.
If we want the APIs to return something other than throw NSE then we should take this bug per Andrew and Jan's comments.
Do we expect the code as it is today to expose more security risk than .NET Framework 4.8 does with CAS disabled?
If so, maybe we should begin to throw in 5.0. But IIRC (from the analyses we did for .NET Standard) there are plenty of libraries that assert in quite a simplistic way and are perfectly happy if those asserts just succeed, and would then be broken and need modification.
@danmosemsft I agree this is probably the best balance. I've already spoken offline with Immo about CAS-related APIs being good candidates for his "better obsolescence" idea. Maybe that gives us a good place to start.
A tricky part of getting SecurityManager to return the correct value is that it would require re-introducing the logic within the Evidence class and other CAS-related types. That logic has by and large been ripped out of .NET Core because we have no good way of evaluating evidence. Evaluating evidence inappropriately could lead to the problems Jan mentioned above.
Activity
danmoseley commentedon Jan 13, 2020
@GrabYourPitchforks any concerns? I think our intent was to behave as if we were always in full trust.
danmoseley commentedon Jan 13, 2020
There's others, eg., ResolvePolicy probably ought to return
new PermissionSet(PermissionState.Unrestricted);as well.jkotas commentedon Jan 14, 2020
That was one principle. Another principle was to try to avoid silently introducing security bugs if the code depends on CAS. That's why some of the stub methods throw instead of just being a no-op. For example, consider this code that somebody might have written using
GetStandardSandbox:If you make GetStandardSandbox to return unrestricted permission set, you will introduce security bug in this code.
GrabYourPitchforks commentedon Jan 14, 2020
Honestly that's why I'd prefer all these methods to throw NSE. CAS has been broken for years and we don't want to encourage people to bring existing CAS-related code forward.
If we want the APIs to return something other than throw NSE then we should take this bug per Andrew and Jan's comments.
danmoseley commentedon Jan 14, 2020
Do we expect the code as it is today to expose more security risk than .NET Framework 4.8 does with CAS disabled?
If so, maybe we should begin to throw in 5.0. But IIRC (from the analyses we did for .NET Standard) there are plenty of libraries that assert in quite a simplistic way and are perfectly happy if those asserts just succeed, and would then be broken and need modification.
Is the current state the best balance?
GrabYourPitchforks commentedon Jan 14, 2020
@danmosemsft I agree this is probably the best balance. I've already spoken offline with Immo about CAS-related APIs being good candidates for his "better obsolescence" idea. Maybe that gives us a good place to start.
danmoseley commentedon Jan 14, 2020
OK. @AArnott can the calling code use an alternative approach here?
GrabYourPitchforks commentedon Jan 14, 2020
A tricky part of getting
SecurityManagerto return the correct value is that it would require re-introducing the logic within theEvidenceclass and other CAS-related types. That logic has by and large been ripped out of .NET Core because we have no good way of evaluating evidence. Evaluating evidence inappropriately could lead to the problems Jan mentioned above.AArnott commentedon Jan 15, 2020
Yes, I think we can remove the calling code.
danmoseley commentedon Jan 15, 2020
Ok, closing