Running runtime code and security

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    Running runtime code and security

    I'd like to include the ability for users to be able to script certain extensibility themselves for an application, i.e. they can create their own add-on scripts in a somewhat similar way to the Microsoft Office suite. However, to throw a security wrench in the works, the software is being built as a web application. So I'd like to know how I go about putting these user scripts in a sandbox so they can't bugger around with things they're not supposed to. For instance, the file system, databases and other such stuff. They should only be able to evaluate logical data that exists in the context of the expression and contained variables.

    Has anyone had to do this before? If so, what approach did you take?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Wow. I was about to link to your own post about creating the expression evaluator when I realized it was already you asking the question.
    I really do NOT like the new "first message" format.

    You could restrict them to applying their scripts on things contained in their own Session object, then control what can and cannot be put into the session object?

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Originally posted by Plater
      Wow. I was about to link to your own post about creating the expression evaluator when I realized it was already you asking the question.
      I really do NOT like the new "first message" format.

      You could restrict them to applying their scripts on things contained in their own Session object, then control what can and cannot be put into the session object?
      Hehe, the math part of the equation was a cakewalk - now I'm getting into the logic part of the equation...whic h I'm still looking for inspiration on. I have some ideas:

      CodeDom.Compile r - Not sure if or how I can sandbox this to prevent security issues, probably using thread.principa l to verify security permissions - but then I have to worry about system security outside of the application, which to be honest, I'm not enthused about.

      Custom Parser - Probably the way I will go because it's the only way I can think of to create a sandbox to prevent security issues.

      Domain Specific Languages - not sure if this is a dead end or not yet, I havent finished my investigation.. . but so far, it's looking like more work than I wanted to put in for such a minor piece of the application.

      I was just reading a nifty article about parse trees by a guy called John Kennedy at Santa Monica College and it took me back to my university days. It's definitely something that anyone trying to tackle this type of challenge should read - it's at:



      Alas, all the code contained within is in Pascal - so probably not useful to everyone. But I found it pretty interesting...

      Sadly, it only really takes me part way - the equation evaluator - and to be honest, my equation evaluator is about as advanced as it needs to be for this application, and only took half as much technical ingenuity to code it - it takes the exact same route as if you'd figured it out by hand and the pattern recognition approach a human uses. If I needed something more advanced I would pursue the parse trees and probably build something more technically advanced to cover the greater scope.

      Right now though, I think it just boils down to inspiration, I've not come across anything sexy enough. All the solutions I've come across are either just ugly or are not only ugly, but far more code than I think should be necessary...

      Comment

      Working...