caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Securely loading and running untrusted modules
@ 2005-04-05 12:14 Richard Jones
  2005-04-05 12:55 ` [Caml-list] " Nicolas Cannasse
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Jones @ 2005-04-05 12:14 UTC (permalink / raw)
  To: caml-list

Suppose I wanted to set up a website where people could upload
untrusted .ml files and have them be compiled and run on my server.
(This would be used as an OCaml teaching tool).  The uploaded
"untrusted.ml" source files would be compiled on the server by
"ocamlc", then loaded using:

  Dynlink.init ();
  Dynlink.allow_only ["SafeAPI"];
  Dynlink.loadfile_private "untrusted.cmo"

where SafeAPI is a module which defines a safe, trusted subset of the
API where only Good Things are allowed.

I don't want the modules to be able to do Bad Things, where Bad Things
is stuff like:

* Reading and writing local files.
* Corrupting memory.
* Inserting executable code into memory.
* Executing arbitrary functions from the server.
* Denial of service (infinite loops, unlimited resource allocation).
* Making arbitrary network connections.
* (and so on ...)

To prevent unlimited resource allocation, I'm thinking of using
setrlimit(2) to limit the size of the server process (it would be a
pre-forked Apache server, so causing one process to hit its memory
limit does not constitute a denial of service attack).

To prevent infinite loops, starting an alarm(2) before loading the
module should kill the Apache process if it uses too much CPU time.

I'm fairly sure that the method above should cope with everything
barring bugs in the compiler and bugs in SafeAPI.

Am I thinking right?

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-04-06  5:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-05 12:14 Securely loading and running untrusted modules Richard Jones
2005-04-05 12:55 ` [Caml-list] " Nicolas Cannasse
2005-04-05 13:16   ` Richard Jones
2005-04-05 14:09     ` Alex Baretta
     [not found]     ` <42529C01.2080609@barettadeit.com>
2005-04-05 14:17       ` Richard Jones
2005-04-05 14:36         ` Jacques Garrigue
2005-04-05 20:58           ` sejourne_kevin
2005-04-05 21:02             ` Jacques Garrigue
2005-04-06  7:59               ` sejourne_kevin
2005-04-05 14:38         ` Virgile Prevosto
2005-04-05 14:40         ` Daniel Bünzli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).