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 callbacks restrictions (was: About PHP callback) #32

Open
masiqbal opened this issue Jun 24, 2015 · 2 comments
Open

PHP callbacks restrictions (was: About PHP callback) #32

masiqbal opened this issue Jun 24, 2015 · 2 comments

Comments

@masiqbal
Copy link

PHP callback is great. But it has security problem when we are in shared environment where we offer users to create their own templates only without accessing PHP code.

Imagine how dangerous this code:
{{ php::exec("rm -rf /home") }}

It can be avoided by simply disabling PHP callback, but I think it is good idea to make new directive eg. blitz.allowed_php_functions and blitz.allowed_php_class

@alexeyrybak
Copy link
Owner

I will keep this here, in general I agree with the feature but I will not have time to implement this in near future. Maybe create a quickfix to disable exec, or enable everything from a specific class/namespace. To be fair, I added callbacks just because "every template system has callbacks" but we (Badoo) never used that much. So any comments and ideas from other users on how to implement these restrictions are all welcomed and appreciated.

@alexeyrybak alexeyrybak changed the title About PHP callback PHP callbacks restrictions (was: About PHP callback) Jun 25, 2015
@ghost
Copy link

ghost commented Aug 12, 2015

It's easy. Just process user template on upload, searching for {{\s_[^:]+:: , and allow only the classes you allow specifically. Also, searching for {{\s_[^\(]+( will help you with finding 'generic' callbacks like {{exec(...)}}, then you may only allow 'q' here, and be safe.

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

No branches or pull requests

2 participants