Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# unverifiable code without unmanaged permission

I have a .net assembly with a method that is not verifiable.

I am trying to load this assembly in a sandbox appdomain.

If I load with skip verification, but not with Unmanaged I get a verification exception. Like so:

new SecurityPermission(SecurityPermissionFlag.Execution | 
                       SecurityPermissionFlag.SkipVerification);

If I load with unmanaged permission it works, but then the app domain won't be enough "sandboxed".

new SecurityPermission(SecurityPermissionFlag.Execution | 
                       SecurityPermissionFlag.SkipVerification |
                       SecurityPermissionFlag.UnmanagedCode);

Also - I am running .Net 4, and to make the above to work I had to switch to transperancy model level 1, like so:

[assembly:SecurityRules(SecurityRuleSet.Level1)]

So, my question is:

  1. Is there a way to run unverified code without UnamangedCode permission.
  2. Is there a way to make the above work with Level2 security ruleset.

Thanks!

like image 998
ravyoli Avatar asked Jun 07 '12 15:06

ravyoli


People also ask

What is the full name of C in C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Is C or C++ same?

While C and C++ may sound similar, their features and usage differ. C is a procedural programming language that support objects and classes. On the other hand C++ is an enhanced version of C programming with object-oriented programming support.

What do you mean by C?

C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.

What is C known for?

It has become one of the most widely used programming languages, with C compilers available for almost all modern computer architectures and operating systems. C has been standardized by ANSI since 1989 (ANSI C) and by the International Organization for Standardization (ISO).


1 Answers

Is there a way to run unverified code without UnamangedCode permission.

Even if there was, you would have given up any security at that point. Unverifiable code has the same power as unmanaged code. It allows you to break the type system for example.

It makes not sense to have SkipVerification and not UnmanagedCode (or the other way around). The two are equivalent and I consider it to be a bug in the framework that both exist.

like image 76
usr Avatar answered Sep 22 '22 23:09

usr