Creating a Sandbox

Discussion in 'Java' started by David 'Bombe' Roden, Nov 24, 2007.

  1. Hi, everyone.

    I'm trying to create a sandbox that executes code loaded from a JAR file
    with reduced privileges. Unfortunately I'm a bit stuck. Here is what I
    tried so far.

    a) Created my own CodeSource and ProtectionDomain, used a custom ClassLoader
    (extending SecureClassLoader) and gave the ProtectionDomain to the
    defineClass class. Then I created an AccessControlContext with the
    ProtectionDomain, used the ClassLoader to load a class from a JAR file and
    tried to execute a method on the JAR file with the created
    AccessControlContext.

    b) Installed a Policy that would return special Permission object when a
    CodeSource from a JAR file is handed to getPermissions(). Then I create two
    classes from two different JAR files, create AccessControlContexts for each
    of them (using their getClass().getProtectionDomain()) and try to execute
    the method: when the method on the first class is called,
    getPermissions(CodeSource) on my custom policy is called but when I execute
    the method of the second class the policy is not asked, even with its
    different ProtectionDomain.

    So far I have not been successful using these (and other, more desperate)
    methods. Is it really so hard to create a sandbox or am I missing some
    important point? Also, it's hard to find examples or other documentation on
    how to execute code with _less_ privileges, most of the code using
    AccessController.doPrivileged() is aimed at executing code with _more_
    privileges.


    Grateful for any hints,

    David
    David 'Bombe' Roden, Nov 24, 2007
    #1
    1. Advertising

  2. Andrew Thompson, Nov 24, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmed Moustafa

    What is a sandbox?

    Ahmed Moustafa, Aug 23, 2003, in forum: Java
    Replies:
    1
    Views:
    380
    Roedy Green
    Aug 23, 2003
  2. Tim Tyler

    Application in sandbox

    Tim Tyler, Nov 27, 2004, in forum: Java
    Replies:
    24
    Views:
    894
    Intel Inside
    Dec 4, 2004
  3. Replies:
    4
    Views:
    438
    Roedy Green
    Sep 27, 2005
  4. Thomas G. Marshall
    Replies:
    6
    Views:
    423
    Thomas Hawtin
    Oct 20, 2005
  5. Vin

    Google's Sandbox

    Vin, Feb 13, 2005, in forum: HTML
    Replies:
    1
    Views:
    431
    Barbara de Zoete
    Feb 13, 2005
Loading...

Share This Page