473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Embedding secure scripting language in PHP (req PHP internals expert)


I need to expose some scripting functionality to novice users in a project
of mine. What i wonderd was if anyone knew a way of executing secure PHP
from within a PHP script or an alternative embedded scripting method? Some
interaction between the PHP script host and the secure embedded script are
needed.

I'm currently i'm playing with ASP.NET(C#) and embeded
jscript(spidermonkey) via managed C++ library but it's quite alot of work,
complex.

I already know about runkit but last time i checked it was pretty broken
and lacked execution time limits; I also emailed the author but got no
reply. Perhaps just fixing runkit myself would be a simpler option? Is
this a viable option, can runkit be fixed up to properly secure a PHP
context? Spawning a seperate process for every request is pretty much out
of the question as it's too expensive for what i have in mind, this is for
a windows host so.

I need to allow looping, branching and basic PHP features but no access to
OS resources and absolutely no file system access. I'd also need a way to
impose memory and CPU time restrictions.

Thanks for any help.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Sep 28 '06 #1
2 1573

"Nemon" <ne***@home.fake.comwrote in message
news:op.tgle7lu5no4rwm@nautilus...
<snip />
I need to allow looping, branching and basic PHP features but no access to
OS resources and absolutely no file system access. I'd also need a way to
impose memory and CPU time restrictions.
hehe sounds a lot like a plain vanilla shared hosting account :-)

one host I deal with will let you do limited system things like
system("ls -l",$ret);
but won't let you do chmod,create or write to a file (unless directory
permissions are set to 757) since php comes in as an other user.

I guess you could always redefine system, fopen and a few other functions so
that they allow url opeing where appropriate but not local files.
and then make it so that the code interface is via php so you control what
gets uploaded and run.

and you can set both timeout and max memory usage in php.ini
Sep 29 '06 #2
On Fri, 29 Sep 2006 06:55:46 +0100, Johnny
<re*****************@hotmail.comwrote:
I guess you could always redefine system, fopen and a few other
functions so
that they allow url opeing where appropriate but not local files.
and then make it so that the code interface is via php so you control
what
gets uploaded and run.
I think this is what runkit does through its extension; it creates another
PHP context and hooks certain PHP functions to control access and usage.
Using file system restrictions probably wont work because the host script
does need database/filesystem/network access, it's just the restricted PHP
that shouldnt be allow todo anything but access a provided API and perform
basic PHP language operations. There is afaik no way you can provide a
restricted "eval" like you can in other languages, like Lua. Lua really is
ideal for this sort of restriction but it's an extremely basic quirky
language which is no good atall for web development.

I think runkit might be my soloution but i can only get it to compile
statically linked which means i'm probably going to have to do a complete
build of PHP on windows, not tham i'm affraid of getting my hands dirty
it's just more work i dont need.

I guess im still weighing up whether ASP.NET + Spidermonkey will be a
better soloution than doing a complete rebuild of PHP + fixed runkit.
Fixing runkit looks like im really going to have todo my homework on the
PHP Zend engine and go on a serious bug hunt. I found some pretty basic
bugs in runkit that i wasn't expecting to find. Things like not allocating
space and corrupting the stack.... made me lose a little faith in runkits
security.

I really need some PHP internals guru to chime in.

Sep 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Sarah Tanembaum | last post by:
I was wondering if it is possible to create a secure database system using RDBMS(MySQL, Oracle, SQL*Server, PostgreSQL etc) and web scripting/programming language(Perl, PHP, Ruby, Java, ASP, etc)...
23
by: Robey Holderith | last post by:
Anyone know a good way to embed python within python? Now before you tell me that's silly, let me explain what I'd like to do. I'd like to allow user-defined scriptable objects. I'd like to...
2
by: Roose | last post by:
With some googling I have found these resources: http://docs.python.org/ext/win-dlls.html http://www.python.org/doc/faq/windows.html I have a large Win32/MFC/C/C++ application that has an...
13
by: Rolf Magnus | last post by:
Hi, I would like to embed a python interpreter within a program, but since that program would be able to automatically download scripts from the internet, I'd like to run those in a restricted...
1
by: Tommy Nordgren | last post by:
I want to write an application that embeds and extends (at least) the Python and Perl interpreters. Now i want to find as much as possible about the Python tools used for extending and embedding...
1
by: C.W. | last post by:
I am trying to connect to a remote server in order to perform an http post inside my asp.net page. However, I consistently get the following error: System.Net.Sockets.Socket.Receive(Byte...
18
by: rodmc | last post by:
Is it possible to embed a Python application within Internet explorer? If so how do people recommend going about it. As for the application it has to be able display simple animated graphics...
6
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.