create-function

PHP sandbox/sanitize code passed to create_function

旧时模样 提交于 2019-11-28 12:57:13
I am using create_function to run some user-code at server end. I am looking for any of these two: Is there a way to sanitize the code passed to it to prevent something harmful from executing? Alternately, is there a way to specify this code to be run in a sandboxed environment so that the user can't play around with anything else. Thanks! http://php.net/runkit You could use the tonkenizer to figure out what the code will do, then whitelist certain functions and operations. I think it would end up being very difficult (or impossible) to make it foolproof, especially given PHP's flexibility: $f

PHP sandbox/sanitize code passed to create_function

你离开我真会死。 提交于 2019-11-27 07:20:30
问题 I am using create_function to run some user-code at server end. I am looking for any of these two: Is there a way to sanitize the code passed to it to prevent something harmful from executing? Alternately, is there a way to specify this code to be run in a sandboxed environment so that the user can't play around with anything else. Thanks! 回答1: http://php.net/runkit 回答2: You could use the tonkenizer to figure out what the code will do, then whitelist certain functions and operations. I think