Note that there are some explanatory texts on larger screens.

plurals
  1. POSecurity issues with online-judge
    text
    copied!<p>I am involved in making an online-programming-judge supporting C/C++ like SPOJ,UVA etc on Linux machine(Ubuntu). The code itself is in C++ . I have to prevent the server from malicious code.<br> I plan to implement security in 2 steps.<br> 1. By jailing (sandboxing) the executing code with chroot system call in a folder with restricted environment. I came across a utility <a href="http://olivier.sessink.nl/jailkit/">Jailkit</a>, but i think the system call alone will suffice my work as i don't have to jail the users, only the executing code. For creating a run time environment in folder i copied the following files along with files for creating a restricted shell (only shell builtin are allowed)</p> <p><code>$ ldd ./a.out<br> linux-gate.so.1 =&gt; (0x00f4c000) libstdc++.so.6 =&gt; /usr/lib/libstdc++.so.6 (0x007a5000)<br> libm.so.6 =&gt; /lib/tls/i686/cmov/libm.so.6 (0x00b80000)<br> libgcc_s.so.1 =&gt; /lib/libgcc_s.so.1 (0x00e0c000)<br> libc.so.6 =&gt; /lib/tls/i686/cmov/libc.so.6 (0x00110000)<br> /lib/ld-linux.so.2 (0x00f7c000)</code> </p> <p>where a.out is an executable c++ file.</p> <p><strong>Problems encountered:</strong><br> i)I have tried few programs which are running fine in jail. But can anybody confirm that these file will be sufficient for all algorithm-intensive codes i.e no need to handle any system call explicitly.<br> ii) It will be great if anybody can suggest any method to restrict some system calls by restricting runtime libraries supplied to jail folder as fork(),socket() etc which are not expected by a code.<br> iii) Just for sake of knowing, i have also copied the file shown by <code>ldd /usr/bin/gcc</code> and /usr/bin/gcc. But i am unable to use gcc in jail with error<br> <code>bash-4.1# /usr/bin/gcc try.c gcc: error trying to exec 'cc1': execvp: No such file or directory</code><br> How can i fix it?</p> <p>2.By tracing the system calls with the help of <a href="http://www.linuxjournal.com/article/6100">ptrace</a> and KILLing the running code if it uses some suspicious system calls. Now problem is of what system calls should be banned ? What i feel is restricting <strong>fork(), vfork(), and execve()</strong> will do the work because there is a time limit( hardly > 10 sec) for each program to execute. After that it will be automatically killed and there is no other way to create another process except fork(), vfork(). But since my thoughts are bounded by my imagination, it will be great if anybody got other opinions to bend the things here.</p> <hr> <p>So basically i am worried about i) and ii) point in "problems encountered" and if somebody can think of a way to hack after restrictions pointed in 2nd point.</p>
 

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