Html may contain small fragments of the built-in Javascript (for example, defined in onclick event handlers).
If I were writing an HTML browser using dotNet, such as C #, which technologies or APIs could use to run such Javascript fragments, given that I do not receive it until runtime (and I get it as string data, not how is the executable code)?
Easier or harder if the code to be run is C # snippets, not Javascript?
Is there any method that does not require my code to have unusual privileges? For example, a method of type CodeCompiler.FromSource requires SecurityPermissionFlag.UnmanagedCode (which seems excessive to me: I donβt understand why it is so risky to compile code).
If I controlled the server side, as well as the client-side code, I could also consider compiling such script fragments on the server, and not on the client, and then send it as pre-compiled code to the client side should be executed. Is there a way to send such a code (dotNet assembly, presumably) over the network to the client, get the code on the client side from the network to RAM on the client side and call it on the client side, without saving it as a file on the client disk?
Edit
I have an answer to the first three questions: I put up with the fact that compilation accepts high privileges. I do not understand why; it is possible (although I do not consider this a very convincing reason), because the compiler is implemented using unmanaged code. Perhaps this will change when they redefine the compiler using managed code, perhaps in the "C # version 5" timeframe. In any case, whatever the reason, it looks like there is, and there are no workarounds (other similar APIs, but which require fewer privileges).
My remaining question is how to get an assembly instance from one machine to another. When I have time, I will find out if the untrusted code can run the Assembly.Load(byte[] rawAssembly) method Assembly.Load(byte[] rawAssembly) .
Chrisw
source share