Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It turns out that <code>javax.scripting</code> does not offer a security framework. After some searching I found a document in Google's cache that suggested trying to use Java's <code>doPrivilegedAction</code> framework but after some experimentation, I was unable to get this to prevent the scripts from opening sockets or accessing the filesystem.</p> <p>After I asked this question I discovered it was previously asked here on StackOverflow: <a href="https://stackoverflow.com/questions/93911/how-can-you-run-javascript-using-rhino-for-java-in-a-sandbox">How can you run Javascript using Rhino for Java in a sandbox?</a> On that page, it falsely indicates that the Rhino included in the JDK6 has security worked out already. As I indicated, I was able to open sockets and other harmful actions from the script.</p> <p>In the end I abandoned <code>javax.scripting</code> and embedded Rhino directly. By building a custom <code>ContextFactory</code> that is also a <code>ClassShutter</code> I was able to achieve two results easily:</p> <ol> <li>Restricts script execution time to a maximum time limit</li> <li>Restricts class access to those I have white-listed, which is basically <code>java.lang.*</code> and a select few classes in my server's hierarchy.</li> </ol> <p>CodeUtopia (which I can't link to because, as a new user, I'm not allowed to link to multiple pages in a single post; but it's linked in the other StackOverflow post) was valuable in describing the <code>ClassShutter</code> architecture and Rhino's own <code>ContextFactory</code> API page describes how to build a custom <code>ContextFactory</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload