-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe extension is not working #124
Comments
The
is rejected both by ghc and by hint. I would thus say that hint is working as expected with respect to the Safe language extension. I recommend taking a closer look at the documentation for the Safe language extension in order to double-check your understanding of how the feature works. If you still think the Safe language extension is not working as documented, please open a ticket on the ghc issue tracker, not hint's. That being said, I do not recommend running untrusted code using hint, with or without the Safe language extension. While you can easily restrict which functions the user has access to using The kind of projects for which hint is well-suited are things like loading a Haskell-based configuration file à la xmonad, or a spreadsheet program which uses Haskell as its expression language; desktop programs in which the user running the program is the same as the user writing the Haskell code being interpreted, and thus the user doesn't have an incentive to write malicious code in order to hack into their own computer. If you want to run untrusted code from the internet, I recommend building a much thicker defence layer around the untrusted code, e.g. by running it inside a virtual machine or something like that, don't run it directly inside your Haskell process. Or, even better, define a smaller DSL which only includes the actions you do want to allow your users to perform, and then parse and interpret it. Don't give your users access to the entire Haskell language when a smaller language will do; when security matters, the smaller the attack surface, the better! |
Looks like the Safe extension is going away anyway. |
Thanks for explaining. Yeah safe feature looks not very practical. I tested same source file with safe pragma on with ghc and hint. Ghc reports violation, hint doesn't. That's why I filed my concern. I am going to use haskell-src-ext to ensure safe imports and extensions. It is very easy to get AST for a file top. |
Reopening the ticket, that does sound like a bug. Could you give more details about how you tested on the ghc side? I cannot reproduce:
|
Hi,
hint is for 3rd party running code provided by the end user,
but I was not able to find how to control access to packages from script code.
Let's looks at example. System.Process modules allows to launch anything.
I put Safe extension in 2 different ways to prevent running script importing System.Process and it is ignored.
Interpreter:
I use ghc (8.8.4) provided from stack.
The text was updated successfully, but these errors were encountered: