-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove CAS era security checks around resource loads and stack crawls #11698
Comments
Unfortunately, there is a ton of legacy APIs that were added during netstandard2.0 push whose behavior depend on the caller. The caller is basically passed in as an implicit argument to the API. Most of these StackCrawlMarks are there to support these APIs. There may be a few that are doing this by accident, but I do not think it is possible to cleanup most of this without breaking stuff.
Yes, this one can be cleaned up probably. The flag is passed in through many layers. It should be cleaned up from all layers - it will allow us to double check that it is not used by anything important. |
skipSecurityCheck all seems to end up here, https://github.com/dotnet/coreclr/blob/75c8c54950c78f1192e481a5bbd6eeff1b3bd1cd/src/vm/pefile.cpp#L1787-L1807 and from looking at AccessCheckType it mixes visibility checks (which we want to keep) and transparency related checks. If that enum can be simplified, then code can be simplified further up. |
I think this cleanup would be valuable, but I do not plan to do this analysis. |
I did some further analysis and found that not only the checks are quite useless security-wise, but some of them have been broken for quite a while. Effectively the check listed in the previous comment says that private embedded manifest resources are allowed to be accessed when the caller is the within the same assembly as the resources (or a friend assembly). The documentation says that it should be allowed to access those private resources when So the only thing that should actually be prevented is the visibility check with Another problem is that the stack crawl mark is not always passed through correctly. Look at the following code: If Numerous other comments suggest that the checks are not very useful (and sometimes propagate stack mark pointing into CoreLib too): The above code in This doesn't consider friend assemblies though, which should be allowed to access private resources. Most of the problems went unnoticed because there are no tests for it. The private embedded manifest resources are also extremely rare. CoreRT doesn't have any of the checks. This issue should be resolved in order to allow moving rest of What is the preferred solution?
|
Correct.
DisablePrivateReflection is about preventing invocation (i.e. running code). It does not prevent inspection (ie. reading stuff - getting MethodInfo for private methods, etc.). Resource reading is inspection. I think we should remove these checks altogether. Thanks for a great analysis! |
Great, thanks for confirming it. I will submit a PR to remove the checks. |
I assume everything related to
skipSecurityCheck
andstackMark
in the resource loading in corelib and VM is related to CAS and can be removed. But what aboutStackCrawlMark
in general. It is in 70 places in the VM. Is it all simply for CAS link demand checks, and we can remove it everywhere?@jkotas
The text was updated successfully, but these errors were encountered: