Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to securely embed the F# compiler in a asp.net web app

I am developing a asp.net web app enabling users to submit F# code, which should be dynamically compiled and executed on the server. I was thinking of either hosting the F# compiler in the web app using the approach shown here: https://fsharp.github.io/FSharp.Compiler.Service/compiler.html Or use F# interactive: http://fsharp.github.io/FSharp.Compiler.Service/interactive.html

The idea would be to dynamically compile the F# code and then load it as an assembly in c# or have F# interactive interpret the code. However, my main concern is security and how to stop the end user from executing arbitrary code. Is there an easy way to restrict this? Thanks!

like image 375
BigONotation Avatar asked Apr 25 '16 09:04

BigONotation


1 Answers

This is an old question and things have considerably changed since it was asked. Now the Fable team have managed to run the F# compiler inside of a web-worker, removing the need to execute code on the server-side. This side-steps all of the security concerns around executing untrusted code.

  • You can try out the REPL here.
  • You can view the source-code here.
like image 110
sdgfsdh Avatar answered Oct 18 '22 13:10

sdgfsdh