Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Aug 26, 2014 2:34 pm 
Offline
Newbie

Joined: Tue Aug 19, 2014 4:21 pm
Posts: 4
Hello,

I have one Linode 2Gb running Debian on which I run my personal website, and a couple of websites of other people. Now, I teach programming at a university and I need to set up some form of automated assessment for students programs (in different languages). The University has some basic setup for that, but it doesn't work very well.

I first thought I could just set up qemu machines on the Linode, with a shared /usr partition image mounted read-only, but then I checked this thread: https://forum.linode.com/viewtopic.php?f=20&t=4749 -- it doesn't seem to be a good idea to run qemu on a Linode.
(It is very important to me that my Linode doesn't hang, and that all other websites keep running as usual)

So I thought I could then set up chrooted environments, to which students will have no login access. They would submit code, which would be compiled or interpreted according to the language, and executed as non-root user by a daemon:

1. Student submits file to a web server. The file is put on that students' chroot.
2. Another program, chrooted in that same place, runs the program and puts the output in a file.
3. The output file is read by a program outside the chroot, and compared to an expected output.
4. The result is published on a webpage so the student has his feedback.

A single /usr directory would be used for all chroots, and mounted readonly, and each student would have his /home, /var and /tmp directories.

But I am not sure about the security implications of this. My questions then are:

* Is it possible for a non-root user to break out of the root on a modern Linux kernel?
* If I decide to go with the chroot solution, what should I do besides, of course, dropping root privileges as soon as possible?

Thanks a lot!


Top
   
PostPosted: Tue Aug 26, 2014 3:51 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
My advice, add a second Linode and use LXC containers in Ubuntu 14.04, you may want to use the distro's kernel it may support restriction better than Linodes (I haven't checked what's compiled in Linodes so can't comment).

LXC = Chroot on steriods https://linuxcontainers.org/

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
PostPosted: Tue Aug 26, 2014 3:56 pm 
Offline
Newbie

Joined: Tue Aug 19, 2014 4:21 pm
Posts: 4
Thank you for pointing me to LXC!

Unfortunately, I am really short on money (in my country university teachers have low salaries), and setting up another Linode would be too expensive. I'll see what I can do witih one single Linode, though.


Top
   
PostPosted: Tue Aug 26, 2014 4:11 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
With LXC or any chroot it's still possible for a malicious student to cause havoc, they could for example thrash the disk grinding the server to a halt, use a massive amount of network bandwidth, run malicious scripts etc. On the bright side you can limit cpu and ram usage. Best to keep a close eye on what they're up to ;)

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
PostPosted: Tue Aug 26, 2014 7:42 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
Why would you do that on a public VPS?

Except for the "upload file" part, everything else would be better on a local VM.

Why not setup your testing system in a VM on your local box using the free VirtualBox app, then have your students submit their projects (in a well defined Zip folder) to either your email address or your free public Dropbox folder.

You're burning resources on your public webserver (and opening up all kinds of security issues) for seemingly no good reason.

_________________
Either provide enough details for people to help, or sit back and listen to the crickets chirp.
Security thru obscurity is a myth - and really really annoying.


Top
   
PostPosted: Wed Aug 27, 2014 7:18 am 
Offline
Newbie

Joined: Tue Aug 19, 2014 4:21 pm
Posts: 4
vonskippy: you're right, I should probably run the assessment in batch mode. It would be nice to let them have immediate feedback, though.


Top
   
PostPosted: Thu Aug 28, 2014 10:16 pm 
Offline
Senior Member

Joined: Fri May 02, 2014 5:20 pm
Posts: 58
Website: http://www.sturmkrieg.ru
Location: Richmond
I came across a hacking website that uses a Linode for running exercises. It allows SSH access to anyone, so presumably they have something to prevent malicious activity. They have a website on GitHub: overthewire.org.

No matter what you do, there will probably still be opportunities for people you don't trust to cause trouble.


Top
   
PostPosted: Fri Aug 29, 2014 3:19 pm 
Offline
Senior Member

Joined: Thu Feb 20, 2014 5:06 pm
Posts: 58
John Henry Eden wrote:
I came across a hacking website that uses a Linode for running exercises. It allows SSH access to anyone, so presumably they have something to prevent malicious activity. They have a website on GitHub: overthewire.org.


I'm sure the owner(s) of those servers don't store any sensitive information on them, and are prepared to wipe them at a moment's notice. The OP wants to do this on the same VM as an important web server, which is not a good idea.

If I were doing this, I'd get a cheap dedicated server from OVH and use VirtualBox and Vagrant. Each submission would trigger a script that initializes a Virtualbox VM using "vagrant up", runs the code inside the VM, then collects the output and nukes the VM with "vagrant destroy". If it's setup correctly, the only way a malicious student could cause trouble is by finding a VM escape exploit in Virtualbox, which would be quite an achievement. Should be fairly easy to setup if you're familiar with Vagrant, though preventing excess resource consumption may take some work.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group