2

In a .NET web site I need to get code submitted by users, compile it and execute it. But I need code to be executed in an isolated environment so that no malicious code can harm my system (for instance, no Directory.Delete("C:\Windows") should be ever executed).

Is it possible to execute code in a kind of chroot environment?

ccellar
  • 10,326
  • 2
  • 38
  • 56
German Latorre
  • 10,058
  • 14
  • 48
  • 59

2 Answers2

5

You can compile and run the code in a sandbox. This is a newly created AppDomain with restricted permissions.

Tim Cools
  • 1,162
  • 10
  • 19
1

You can take a look at AppDomains. It's an isolated environment where applications execute. Take a look.

Chris Ledet
  • 11,458
  • 7
  • 39
  • 47