473,854 Members | 1,783 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 1738
http://aspn.activestate.com/ASPN/Coo.../Recipe/496746

jv****@gmail.co m 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
1485
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, instances of this class are instantiated using factory functions. This appears to restrict the sub-classing of NumArray Examples: a sub-class Matrix, an array restricted to two dimensions, or a sub-class Mix, which combines the NumArray with...
5
2457
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. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/271246
0
1660
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 - start_server, stop_server and test_server. The first two do the obvious, the last takes inputs from two cells in the excel sheets, then passes them to the python server which adds them together and returns the result an Excel message dialog.  
5
5331
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 these files, I wish to do the same using another python code instead of running each of these files one by one, which would be cumbersome giving the argv of each file every single time. This can be easily done using a shell script but I just...
7
2741
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>') html = html.replace('</i>','</em>') I can change this to a single call to re.sub: html = re.sub('<(*)i>', r'<\1em>', html)
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 Please enter your name: Then, if the user types myself as the name , the output is OK. Thats all I want it to do (remember, Im just new). The code Ive tryed is:
5
2532
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 would like to understand what was coded originally. thelistOut looks like a hash to me (I'm more familiar with perl). Perhaps someone could translate from perl to python for me - not in code but just in concept. Here is the code. This script...
17
4542
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 functions do this on occasion. This leads to different behaviour across platforms and makes it unnecessarily difficult to properly support all languages. To solve this I propose Python's unicode type using UTF-16 should have gaps in its index,...
10
1638
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 "</tr>" strings: data = import itertools def key(s): if s == "<":
3
1228
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 first post so feel free to creticue, the more you do the faster i learn to post well. Mohed
0
9899
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
9750
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10740
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
9510
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7909
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7076
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
5738
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...
1
4550
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
3182
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.