Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I have in the past and am considering in the future using the Safe module to provide semi-public access to a local Perl interpreter. I'm familiar with all of the options and opcode groups, and can configure it to be what appears to be completely safe as far as executing untrusted code goes. My questions are these:
  1. The Safe documentation makes it plain and clear that using the module is no guarantee of security/safety in executing untrusted code. Barring any undiscovered bugs/exploits, however, is it for all practical purposes reasonably safe to use it in this fashion? Is there some fundamental flaw in its implementation or are there any known ways of circumventing its protection? I realize there's always the possibility of some hole allowing unauthorized access to certain Perl opcodes, but I'm trying to identify the level of risk involved here.
  2. Is there an easy/common way of addressing the DoS aspect of running untrusted code? With Safe, I can prohibit them from executing stuff I don't want them to execute, but I can't keep them from writing a tight while (1) {} loop and tying up the CPU, or making it so the code never returns. My first thought is to use setpriority to reduce adverse affects, and alarm to catch any code running an inordinate amount of time, but is this safe? What if the evil code modifies $SIG{ALRM}?
I realize this is a risky thing to do, and additional security precautions I'm considering involve chroot and others. Can anyone think of any other caveats?

In reply to Known security issues with by Fastolfe

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (6)
    As of 2019-05-20 19:43 GMT
    Find Nodes?
      Voting Booth?
      Do you enjoy 3D movies?

      Results (128 votes). Check out past polls.