views:

67

answers:

1

I need to get pointed in the right direction. I have embedded an Iron Python scripting host into a simple C# application, but now I need to know the best practices for locking down security on a user generated IronPython or IronRuby script.

Specifically, what are the strategies for preventing library imports and isn't there a way in .NET to run a block of code or a thread in a different security context, for instance to prevent file system access? Also, can this context be assigned a built-in level or role rather than an actual user?

Thanks!

+3  A: 

You should run scripting host in different appdomain, and setup Security Policies via Evidence property using sandboxing API

Sergey Mirvoda
Sergey, Would that prevent an IronPython open('c:\\file.txt') call?
Josh Pearce
not sure about Python, but if it opens file using System.IO namespace definitely yes.
Sergey Mirvoda
I guess you're an IronRuby guy. Would a locked down AppDomain prevent ruby's native file methods from working?
Josh Pearce
Of course! remember that IronRuby's native file methods are eventually System.IO operations.
Shay Friedman