ShabbyDoo
ShabbyDoo

Reputation: 1286

How to Sandbox Ant Builds within Hudson

I am evaluating the Hudson build system for use as a centralized, "sterile" build environment for a large company with very distributed development (from both a geographical and managerial perspective). One goal is to ensure that builds are only a function of the contents of a source control tree and a build script (also part of that tree). This way, we can be certain that the code placed into a production environment actually originated from our source control system.

Hudson seems to provide an ant script with the full set of rights assigned to the user invoking the Hudson server itself. Because we want to allow individual development groups to modify their build scripts without administrator intervention, we would like a way to sandbox the build process to (1) limit the potential harm caused by an errant build script, and (2) avoid all the games one might play to insert malicious code into a build.

Here's what I think I want (at least for Ant, we aren't using Maven/Ivy right now):

I can think of three ways to implement this:

  1. Write an ant wrapper that uses the Java security model to constrain access
  2. Create a user for each build and assign the rights described above. Launch builds in this user space.
  3. (Updated) Use Linux "Jails" to avoid the burden of creating a new user account for each build process. I know little about these though, but we will be running our builds on a Linux box with a recent RedHatEL distro.

Am I thinking about this problem correctly? What have other people done?

Update: This guy considered the chroot jail idea:

https://www.thebedells.org/blog/2008/02/29/l33t-iphone-c0d1ng-ski1lz

Update 2: Trust is an interesting word. Do we think that any developers might attempt anything malicious? Nope. However, I'd bet that, with 30 projects building over the course of a year with developer-updated build scripts, there will be several instances of (1) accidental clobbering of filesystem areas outside of the project workspace, and (2) build corruptions that take a lot of time to figure out. Do we trust all our developers to not mess up? Nope. I don't trust myself to that level, that's for sure.

With respect to malicious code insertion, the real goal is to be able to eliminate the possibility from consideration if someone thinks that such a thing might have happened.

Also, with controls in place, developers can modify their own build scripts and test them without fear of catastrophe. This will lead to more build "innovation" and higher levels of quality enforced by the build process (unit test execution, etc.)

Upvotes: 1

Views: 1462

Answers (3)

Robert Munteanu
Robert Munteanu

Reputation: 68278

I suggest you have 1 Hudson master instance, which is an entry point for everyone to see/configure/build the projects. Then you can set up multiple Hudson slaves, which might very well be virtual machines or (not 100% sure if this is possible) simply unprivileged users on the same machine.

Once you have this set up, you can tie builds to specific nodes, which are not allowed - either by virtual machine boundaries or by Linux filesystem permissions - to modify other workspaces.

Upvotes: 1

Michael Donohue
Michael Donohue

Reputation: 11876

How many projects will Hudson be building? Perhaps one Hudson instance would be too big, given the security concerns you are expressing. Have you considered distributing the Hudson instances out - one per team. This avoids the permission issue entirely.

Upvotes: 0

Scott Markwell
Scott Markwell

Reputation: 1111

This may not be something you can change, but if you can't trust the developers then you have a larger problem then what they can or can not do to your build machine.

You could go about this a different way, if you can't trust what is going to be run, you may need a dedicated person(s) to act as build master to verify not only changes to your SCM, but also execute the builds.

Then you have a clear path of responsibilty for builds to not be modified after the build and to only come from that build system.

Another option is to firewall off outbound requests from the build machine to only allow certain resources like your SCM server, and your other operational network resources like e-mail, os updates etc.

This would prevent people from making requests in Ant to off the build system for resources not in source control.

When using Hudson you can setup a Master/Slave configuration and then not allow builds to be performed on the Master. If you configure the Slaves to be in a virtual machine, that can be easily snapshotted and restored, then you don't have to worry about a person messing up the build environment. If you apply a firewall to these Slaves, then it should solve your isolation needs.

Upvotes: 2

Related Questions