[Sugar-devel] programming on thin ice

Benjamin M. Schwartz bmschwar at fas.harvard.edu
Thu Jan 29 21:59:55 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Walter Bender wrote:
> (1) A simple idea I am exploring are to allow Turtle Art users to
> enter simple Python commands directly into a block, as per
> http://sugarlabs.org/go/Image:Ta-sin.png

Beautiful.

> But here is my question:
> 
> My code for #1 above is:
> 
> def myfunc(lc, f, x):
>     myf = "def f(x): return " + f
>     userdefined = {}
>     try:
>         exec myf in globals(), userdefined
>     except:
>         raise logoerror("#syntaxerror")
>     return userdefined.values()[0](x)
> 
> What I am concerned about is making the system vulnerable by letting
> arbitrary functions to execute within TA.

Don't worry about it.  Three reasons:

1.  You're right.  Rainbow's protections here are strong.  The
user-modified code can neither read nor write nor overwrite the contents
of the Journal, for example.  There are lots of other bad things it could
do, like fill the disk with junk, break the TurtleArt icons so that
TurtleArt won't start, or flood the network, but

2.  the user is writing this code themselves.  They'd have to go to great
lengths, just to (very temporarily) break their own machine.  Besides,

3.  the remaining issues in (1) should be fixed inside Rainbow, rather
than ineffectually patched by each Activity.

- --Ben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkmCbSsACgkQUJT6e6HFtqQJ0QCfVxkCYZiDYIGp7m68cCBWoyRu
fwsAoI14YV8XDcDeA1lO5WC2ZbUVKwp0
=mNfY
-----END PGP SIGNATURE-----


More information about the Sugar-devel mailing list