473,508 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python "sub-interpreter," security

Hello, I am writing a pure-Python game engine that interprets the code
of game objects within the same process with the exec statement. My
main goal is to make as much power available as possible and exec seems
like the best way to do that.

This is my "proof-of-concept" code(only 18 lines and some whitespace,
including the test):

http://people.ucsc.edu/~jhofmann/programmables.py

I showed this to the Pygame list and recieved some interest and a
completely different, more sophisticated implementation:

http://codereactor.net/~shang/interpret/

As-is, both versions are wide-open security holes. I think that I can
patch them up if I run checks on the statements and eliminate all
language features that pose risks. Then, features that are useful but
not needed at their full capacity can be accessed through functions
designed to be secure. Forcing a crash is not considered an exploit for
this purpose(since it's a game engine - if it crashes, the user can
recover and lose no data)

What I'd like to know is, is it possible to meet this level of
security, and if so, which features have to be eliminated?

The two that I'm sure should go are module imports and self-modifying
code. But in the latter case, I don't know all the ways that might be
done. It seems like a very complicated problem, and if I can't solve it
I might leave the whole thing unsecured.

Jun 26 '06 #1
2 1719
http://aspn.activestate.com/ASPN/Coo.../Recipe/496746

jv****@gmail.com wrote:
Hello, I am writing a pure-Python game engine that interprets the code
of game objects within the same process with the exec statement. My
main goal is to make as much power available as possible and exec seems
like the best way to do that.

This is my "proof-of-concept" code(only 18 lines and some whitespace,
including the test):

http://people.ucsc.edu/~jhofmann/programmables.py

I showed this to the Pygame list and recieved some interest and a
completely different, more sophisticated implementation:

http://codereactor.net/~shang/interpret/

As-is, both versions are wide-open security holes. I think that I can
patch them up if I run checks on the statements and eliminate all
language features that pose risks. Then, features that are useful but
not needed at their full capacity can be accessed through functions
designed to be secure. Forcing a crash is not considered an exploit for
this purpose(since it's a game engine - if it crashes, the user can
recover and lose no data)

What I'd like to know is, is it possible to meet this level of
security, and if so, which features have to be eliminated?

The two that I'm sure should go are module imports and self-modifying
code. But in the latter case, I don't know all the ways that might be
done. It seems like a very complicated problem, and if I can't solve it
I might leave the whole thing unsecured.


Jun 26 '06 #2

faulkner wrote:
http://aspn.activestate.com/ASPN/Coo.../Recipe/496746


Thanks! I was searching everywhere but couldn't find the right terms, I
guess.

Jun 26 '06 #3

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

Similar topics

0
1456
by: Colin J. Williams | last post by:
numarray is a package which is under development and intended to replace Numeric, an efficient and operational package. One of the classes in numarray is NumArray. As currently implemented,...
5
2425
by: Premshree Pillai | last post by:
Hello, I recently wrote a Perl version of pyAlbum.py -- a Python script to create an image album from a given directory -- plAlbum.pl . It made me realize how easy-to-use Python is. ...
0
1642
by: justin worrall | last post by:
Hi,   I have a very simple python win32 example (gleaned from the O'Reilly book on Win32 programming for Python), of an Excel client with a COM server. Essentially I have three VB buttons -...
5
5293
by: Shalen chhabra | last post by:
Hey, Can anyone give me a snippet for running a python program over all the files in the directory. For ex: I have ten files in a directory and I want to run a python program against all of...
7
2719
by: Iain King | last post by:
I have some code that converts html into xhtml. For example, convert all <i> tags into <em>. Right now I need to do to string.replace calls for every tag: html = html.replace('<i>','<em>')...
25
497
by: Byte | last post by:
I know this is probably a stupid question, but I'm learning Python, and am trying to get the if function to work with letters/words. Basicly, I'm trying to write a script that when run, says ...
5
2514
by: Karyn Williams | last post by:
I am new to Pyton. I am trying to modify and understand a script someone else wrote. I am trying to make sense of the following code snippet. I know line 7 would be best coded with regex. I first...
17
4506
by: Adam Olsen | last post by:
As was seen in another thread, there's a great deal of confusion with regard to surrogates. Most programmers assume Python's unicode type exposes only complete characters. Even CPython's own...
10
1607
by: 7stud | last post by:
I'm applying groupby() in a very simplistic way to split up some data, but when I timeit against another method, it takes twice as long. The following groupby() code groups the data between the...
3
1202
by: Mohed | last post by:
Hello. I am interrested in seeing the source code for all the nativ builtin methods and clases in python. Is there a webpage that lists them or is this done easier some other way. This is my...
0
7227
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
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
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
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3204
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
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 ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
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...

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.