[Python-Dev] Capabilities / Restricted Execution (original) (raw)
Scott Dial scott+python-dev at scottdial.com
Sun Jul 16 11:42:30 CEST 2006
- Previous message: [Python-Dev] Capabilities / Restricted Execution
- Next message: [Python-Dev] Capabilities / Restricted Execution
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Talin wrote:
Scott Dial wrote:
Phillip J. Eby wrote:
A function's funcclosure contains cell objects that hold the variables. These are readable if you can set the funcclosure of some function of your own. If the overall plan includes the ability to restrict funcclosure setting (or reading) in a restricted interpreter, then you might be okay. Except this function (getattribute) has been trapped inside of a class which does not expose it as an attribute. So, you shouldn't be able to get to the funcclosure attribute of the getattribute function for an instance of the Guard class. I can't come up with a way to defeat this protection, at least. If you have a way, then I'd be interested to hear it. I've thought of several ways to break it already. Some are repairable, I'm not sure that they all are. For example, neither of the following statements blows up: print t2.getname.funcclosure[0] print object.getattribute( t2, 'dict' ) Still, its perhaps a useful basis for experimentation. -- Talin
I quickly poked around it in python and realized that in 2.5 (as opposed to the 2.4 python I was playing in) the cell object exposes cell_contents.. blargh. So, yes, you can defeat the protection because the wrapped instance is exposed.
print t2.get_name()
t2.get_name.func_closure[0].cell_contents.im_self.name = 'poop'
print t2.get_name()
Although, your second example with using the object.getattribute doesn't seem to really be an issue. You retrieved the dict for the Guard class which is empty and is something we should not feel concerned about being leaked.
Only way I see this as viable is if in "restricted" mode cell_contents was removed from cell objects.
-- Scott Dial scott at scottdial.com scodial at indiana.edu
- Previous message: [Python-Dev] Capabilities / Restricted Execution
- Next message: [Python-Dev] Capabilities / Restricted Execution
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]