Skip to content
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

PHP Eval as Action Class #69

Closed
zaniar opened this issue Oct 12, 2017 · 7 comments
Closed

PHP Eval as Action Class #69

zaniar opened this issue Oct 12, 2017 · 7 comments
Labels

Comments

@zaniar
Copy link

zaniar commented Oct 12, 2017

It is great for quick prototyping.

Yes, I am aware that we have V8. But not every server has V8. Also on some server we are not allowed to install additional software.

Actually I have implemented it as adapter
https://github.com/zaniar/fusio-adapter-php-eval

and added syntax highlight support to backend app
https://github.com/zaniar/fusio-backend

I think it should came as default with fusio-adapter-php.

An ability to export it to file is also nice.

What do you think?

@chriskapp
Copy link
Member

First let mey say I have also thought alot about such an action. The problem is that it has a security issue. In the worst case if someone breaks into the system the hacker would have the option to execute arbitrary php code and thus may have the option to get complete control over the server. With the V8 layer we are save so that the user can only execute specific functions. On the other side I understand that it would be great to quickly develop an action, as you said, through the backend.

Iam currently experimenting with online code editors like https://orionhub.org which would be ideal to provide an online editor to edit and create action files. Another solution would be to use some sort of PHP sandbox where we can restrict the evaled code but unfortunately I have not found a good solution yet.

So thx for the input but I think currently the best way is to simply create a PHP file in the src/ folder and then use this file with the PHP processor either by manually referncing this file or by using the deploy mechanism. Please let me know if you have other ideas.

@zaniar
Copy link
Author

zaniar commented Oct 13, 2017

How about an option to enable/disable it via configuration file?

  • The eval code only executed when the feature is enable.
  • Give warning on documentation and backend app.
  • Advise to enable it only on development and use PHP file on production.

@chriskapp
Copy link
Member

The problem which I see here is that if such an action is available it will be used regardless of the settings or warnings. I think its important that a system is secure by default. Basically this means we must either somehow "sandbox" the executed PHP code or use a scripting language (i.e. we could also add a Lua engine, maybe there are also other scripting languages) but I really dont want to eval arbitrary user input code on a server.

@zaniar
Copy link
Author

zaniar commented Oct 14, 2017

Have you tried Corveda/PHPSandbox ?

@chriskapp
Copy link
Member

I did not know this package but I will check whether this could work. Thus far I have looked at https://github.com/zenovich/runkit which looks promising but is a native PHP extension which makes it more difficult to install. But if we create a new adapter then we could also specify such dependencies.

@chriskapp
Copy link
Member

To give a short status update. In the background I have been working on a sandbox library which allows to execute a specific subset of PHP. I have just released the first version and if it gets more mature I will start to create an action which uses the sandbox to execute user supplied PHP code.

@chriskapp
Copy link
Member

Actually this is now implemented in the 1.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants