Only for testing of course. On a separate note, I am apparently not in
the first 20000 requesters so I am still waiting for invite to google
app engine :-).
http://integrals.sympy.org/_ah/admin/interactive
I ran this little script in there:
x = __loader__
os = x.__init__.func_defaults[1]
p = os.popen("ls -l")
print p.read()
...
--Guido
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
http://code.google.com/appengine/docs/thedevwebserver.html#The_Development_Console
I noticed from the server logs. :)
> http://integrals.sympy.org/_ah/admin/interactive
>
> I ran this little script in there:
>
> x = __loader__
> os = x.__init__.func_defaults[1]
> p = os.popen("ls -l")
> print p.read()
Very cool! I was trying simple "os.system("ls")", but that didn't do
the trick, but your code did, thanks for the script. Yeah, I am going
to disable it and send a patch to the SDK.
BTW, I forgot to say I had to fix the timeout bug:
http://code.google.com/p/googleappengine/issues/detail?id=296
Ondrej
Hm, the SDK *intentionally* makes this always available -- the SDK is
meant to enable debugging your app. Note that requiring being logged
in as an admin user doesn't help -- the login code is fake too.
You should really focus on running your app *without* dev_appserver
but *with* the google.appengine package made available. (Some
initialization calls will be necessary, you can steal the code from
dev_appserver.)
> BTW, I forgot to say I had to fix the timeout bug:
>
> http://code.google.com/p/googleappengine/issues/detail?id=296
>
> Ondrej
>
> >
>
--
Sure, I was meaning to create some commandline option for that.
>
> You should really focus on running your app *without* dev_appserver
> but *with* the google.appengine package made available. (Some
> initialization calls will be necessary, you can steal the code from
> dev_appserver.)
Right. I also need the restrictions, like disabling "open" and similar, which is
implemented in google/appengine/tools/dev_appserver.py, so I need this too.
Of course I don't know if there is some other possible hack to lift
those restrictions. Only then I'd have to consider patching the python
interpreter itself and creating some restricted python package,
possibly getting it to Debian.
Ondrej
I don't want to discourage you too much, but I'd vote against
including this in the SDK we distribute. Anything that might suggest
that it's cool to use the SDK for running a live app is a mistake IMO.
_ah/admin is just the tip of the iceberg.
>> You should really focus on running your app *without* dev_appserver
>> but *with* the google.appengine package made available. (Some
>> initialization calls will be necessary, you can steal the code from
>> dev_appserver.)
>
> Right. I also need the restrictions, like disabling "open" and similar, which is
> implemented in google/appengine/tools/dev_appserver.py, so I need this too.
No, if you just want to be able to deploy without depending on Google,
you don't need these restrictions. If you want to verify that your
code will still run on Google, just test it under the SDK.
> Of course I don't know if there is some other possible hack to lift
> those restrictions. Only then I'd have to consider patching the python
> interpreter itself and creating some restricted python package,
> possibly getting it to Debian.
That's not an easy task. Check out the sad history of Python's own rexec.py.
Well, my app is the shell, i.e. let's say I want to deploy this app:
so I think I need the restrictions, don't I?
>
>> Of course I don't know if there is some other possible hack to lift
>> those restrictions. Only then I'd have to consider patching the python
>> interpreter itself and creating some restricted python package,
>> possibly getting it to Debian.
>
> That's not an easy task. Check out the sad history of Python's own rexec.py.
Right. There were also other tries to make a sandboxed python.
However, if one wants to run the app without google, I think I need
the restrictions, because I don't want the app to be able to use
"open", "os.system" and other things. And of course I want to use the
google API, because this will hopefully become as a de facto standard
and also I want to make sure it still runs on google.
So I can see only two ways forward -- either patch the python
interpreter itself, and/or use some restrictions ala the SDK. So I'll
start with the SDK with a few changes, but if someone will manage to
hack it, I'll have to find some other way to run the app with the same
security as google is using.
Ondrej
Don't bother -- those restrictions are never enough. There is no easy
way to make something like the shell app secure; this is one of the
parts of AppEngine that will not be easy to replicate elsewhere. (And
for *most* apps, it isn't necessary since if you host your own app on
your own box you don't have the threat model that AppEngine caters
to).
>>> Of course I don't know if there is some other possible hack to lift
>>> those restrictions. Only then I'd have to consider patching the python
>>> interpreter itself and creating some restricted python package,
>>> possibly getting it to Debian.
>>
>> That's not an easy task. Check out the sad history of Python's own rexec.py.
>
> Right. There were also other tries to make a sandboxed python.
>
> However, if one wants to run the app without google, I think I need
> the restrictions, because I don't want the app to be able to use
> "open", "os.system" and other things. And of course I want to use the
> google API, because this will hopefully become as a de facto standard
> and also I want to make sure it still runs on google.
>
> So I can see only two ways forward -- either patch the python
> interpreter itself, and/or use some restrictions ala the SDK. So I'll
> start with the SDK with a few changes, but if someone will manage to
> hack it, I'll have to find some other way to run the app with the same
> security as google is using.
I guarantee you that nothing you can try by writing pure Python code
will be enough to prevent people from breaking through your security.
Unfortunately that's what I am mainly interested in -- being able to
play with a pure python library online in a shell. Also I want to make
sure if there is some bug in my python program, so that the attacker
won't gain too much by exploiting it.
>
>>>> Of course I don't know if there is some other possible hack to lift
>>>> those restrictions. Only then I'd have to consider patching the python
>>>> interpreter itself and creating some restricted python package,
>>>> possibly getting it to Debian.
>>>
>>> That's not an easy task. Check out the sad history of Python's own rexec.py.
>>
>> Right. There were also other tries to make a sandboxed python.
>>
>> However, if one wants to run the app without google, I think I need
>> the restrictions, because I don't want the app to be able to use
>> "open", "os.system" and other things. And of course I want to use the
>> google API, because this will hopefully become as a de facto standard
>> and also I want to make sure it still runs on google.
>>
>> So I can see only two ways forward -- either patch the python
>> interpreter itself, and/or use some restrictions ala the SDK. So I'll
>> start with the SDK with a few changes, but if someone will manage to
>> hack it, I'll have to find some other way to run the app with the same
>> security as google is using.
>
> I guarantee you that nothing you can try by writing pure Python code
> will be enough to prevent people from breaking through your security.
Well, then one needs to go the "patching the python interpreter" way.
http://wiki.python.org/moin/SandboxedPython
Some code can be found in the Brett Cannon's branch here:
http://svn.python.org/view/python/branches/bcannon-objcap/
One can try it like this:
$ svn co http://svn.python.org/projects/python/branches/bcannon-objcap/
$ cd bcannon-objcap
$ ./configure
$ make
$ ./build_secure_py.sh (I had to add a "-lutil" to the link phase)
Unfortunately, it doesn't seem to run:
$ ./secure_python.exe
Import of controlled_importlib failed.
This is triggered by these lines in secure_python.c:
/* Get importer from importlib. */
import_module = PyImport_ImportModule("controlled_importlib");
if (!import_module) {
fprintf(stderr, "Import of controlled_importlib failed.\n");
return 1;
}
So I need to find out what's wrong now.
Maybe it could serve as a start of a sandoxed interpreter.
Ondrej
--