473,804 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(spiderm onkey) 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 1596

"Nemon" <ne***@home.fak e.comwrote in message
news:op.tgle7lu 5no4rwm@nautilu s...
<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.c omwrote:
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
3138
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) combination? I have the following in mind: I wanted to store all my( and my brothers and sisters) important document information such as birth certificate, SSN, passport number, travel documents, insurance(car, home, etc) document, and other...
23
2991
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 give them access to modify pieces of my classes. I'd like to disallow access to pretty much the rest of the modules.
2
2874
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 embedded scripting language (a very limited one). I would like to rip it out and replace it with Python. I am thinking that this would be relatively simple since the scripting language is a very small interface between the UI and the engine --...
13
4036
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 environment, which basically means that I want to allow only a specific set of modules to be used by the scripts, so that it wouldn't be possible for them to remove files from the hard drive, kill processes or do other nasty stuff. Is there any...
1
1836
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 Python. To be more specific: My app should: 1. Parse an input file. 2. Call a script in some scripting language, to generate an output file, for example in C++. For task 2 I need to call an embedded interpreter, and also provide call backs from...
1
6080
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 buffer, Int32 offset, Int32 size, SocketFlags socketFlags) System.Net.Sockets.NetworkStream.Read(Byte buffer, Int32 offset, Int32 size)
18
3043
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 such as circles, lines and squares. However if someone clicks on a shape it should open up another application, such as Word. Thanks, Rod
6
3011
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 interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player = Player() game.loadPlayer(player) player.moveTo(location)
7
4970
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 developed significant content for the C programming language that is available at: https://www.securecoding.cert.org/ by clicking on the "CERT C Programming Language Secure Coding Standard"
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.