| 1 |
<html> |
| 2 |
<head><title>distcc security notes</title> |
| 3 |
<meta name="author" content="Martin Pool"> |
| 4 |
<meta name="keywords" content="distributed, make, build, gcc, |
| 5 |
parallel, network, networked, faster, free, fast, paralel, cc, c, |
| 6 |
C++, Objective C, ObjC, compile, compiler, compilation, |
| 7 |
simple, GPL, GNU, Linux, BSD, Unix, software, development, |
| 8 |
developer, TeamBuilder, quick, dmake, pvmake, |
| 9 |
transparent, easy, workstations, Solaris, IncrediBuild, |
| 10 |
productivity, speed, time, tool, performance, hardware, |
| 11 |
agents, nfs, libraries, source, headers, workload, |
| 12 |
buildfarm, farm, server, cluster, clustered, clustering, MOSIX, OpenMOSIX"> |
| 13 |
<meta name="description" content="distcc is a fast, free distributed C and C++ compiler."> |
| 14 |
<link rel="SHORTCUT ICON" href="favicon.ico"> |
| 15 |
<link type="text/css" rel="stylesheet" href="distcc-green.css"> |
| 16 |
<link type="text/html" rel="top" href="index.html"> |
| 17 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> |
| 18 |
<body vlink="#003300" text="#000000" link="#003300" bgcolor="#ffffff" alink="#336633"><p><table width="100%"><tr><td valign="top"><div class="navbar"><ul> |
| 19 |
<li><a href="index.html">distcc</a></li> |
| 20 |
<li><a href="http://code.google.com/p/distcc/source/browse/trunk">source</a> |
| 21 |
<li><a href="http://code.google.com/p/distcc/downloads/list">binaries</a></li> |
| 22 |
<li><a href="http://distcc.googlecode.com/svn/trunk/NEWS">news</a></li> |
| 23 |
<li><a href="scenarios.html">scenarios</a></li> |
| 24 |
<li><a href="results.html">testimonials</a></li> |
| 25 |
<li><a href="benchmark.html">benchmarks</a></li> |
| 26 |
<li><a href="security.html"><b>security</b></a></li> |
| 27 |
<li><a href="distcc-lca-2004.html">whitepaper</a></li> |
| 28 |
<li><a href="http://distcc.googlecode.com/svn/trunk/doc/web/man/">Man pages</a></li> |
| 29 |
<li><a href="faq.html">FAQ</a></li> |
| 30 |
|
| 31 |
<p> |
| 32 |
<li><a href="http://code.google.com/p/distcc/issues/list">report a bug</a></li> |
| 33 |
<li><a href="https://lists.samba.org/mailman/listinfo/distcc">mailing list</a> |
| 34 |
<ul><li><a href="mailto:[email protected]">post</a></li> |
| 35 |
<li><a href="http://lists.samba.org/archive/distcc/">archive</a></li> |
| 36 |
<li><a href="news://news.gmane.org/gmane.comp.compilers.distcc">newsgroup</a></li></ul> |
| 37 |
</li> |
| 38 |
<li><a href="http://freshmeat.net/projects/distcc">Freshmeat</a> |
| 39 |
<ul><li><a href="http://freshmeat.net/subscribe/28140">be notified</a></li></ul> |
| 40 |
</li> |
| 41 |
|
| 42 |
<p> |
| 43 |
<li>related:</li> |
| 44 |
<ul> |
| 45 |
<li><a title="How to use distcc and Gentoo" href="http://www.gentoo.org/doc/en/distcc.xml">Gentoo</a></li> |
| 46 |
<li><a title="Script to ease building cross-compilers and toolchains" href="http://kegel.com/crosstool/">crosstool</a></li> |
| 47 |
<li><a title="Cache compiler results" href="https://ccache.dev/">ccache</a></li> |
| 48 |
<li><a title="Centralized control over distcc and ccache" href="http://ccontrol.ozlabs.org/">ccontrol</a></li> |
| 49 |
<li><a title="Smart job scheduler" href="http://dmucs.sourceforge.net/">dmucs</a></li> |
| 50 |
</ul> |
| 51 |
<p><p></td> |
| 52 |
<td valign="top"> |
| 53 |
<div class="body"> |
| 54 |
<h1 class="title">distcc security notes</h1> |
| 55 |
|
| 56 |
|
| 57 |
<p> |
| 58 |
distcc is intended to be quite secure when used according to the |
| 59 |
documentation, but it must be properly configured. |
| 60 |
<p> |
| 61 |
<b>Anyone who can connect to the distcc server port can run arbitrary |
| 62 |
commands on that machine as the distccd user. If you are not using |
| 63 |
SSH, you must use the <tt>--allow</tt> rule and/or firewall |
| 64 |
rules to limit access to port 3632.</b> Since version 3.0, distccd now |
| 65 |
enforces that, refusing to run if the --allow option is not specified. |
| 66 |
<p> |
| 67 |
Someone has written a |
| 68 |
<a href="http://www.metasploit.com/projects/Framework/modules/exploits/distcc_exec.pm"> |
| 69 |
program to attack unprotected servers</a>. To prevent this attack, use |
| 70 |
network access control or SSH (which is much slower). |
| 71 |
<p> |
| 72 |
Installation or use of any software caries a certain risk, which |
| 73 |
should be assessed by the machine operator. |
| 74 |
<p> |
| 75 |
distcc allows remote execution of compilation jobs. This introduces a |
| 76 |
trust relationship between the client and server machines. The client |
| 77 |
completely trusts the server to compile code correctly. A corrupt |
| 78 |
server could introduce malicious code into the results, or attack the |
| 79 |
client in other ways. The server completely trusts an authorized |
| 80 |
client. A malicious client could execute arbitrary commands on the |
| 81 |
server. |
| 82 |
<p> |
| 83 |
distcc supports a choice of two network transports: a simple TCP |
| 84 |
protocol (normally on port 3632), and connection over SSH or a similar |
| 85 |
secured connection. |
| 86 |
<p> |
| 87 |
The distccd TCP server does not run as root. If started by root, |
| 88 |
before accepting connections it |
| 89 |
gives away its privileges and changes to either the <tt>distcc</tt> or |
| 90 |
<tt>nobody</tt> user, or to a user specified by the <tt>--user</tt> option. |
| 91 |
<p> |
| 92 |
The distcc client may be run as root. Compiling or doing other |
| 93 |
unnecessary work as root is generally discouraged on Unix, but distcc |
| 94 |
permits it because some package installations require it. |
| 95 |
<p> |
| 96 |
In TCP mode network transmissions are not encrypted or signed. An |
| 97 |
attacker with passive access to the network traffic can see the source |
| 98 |
or object code. An attacker with active access can modify the source |
| 99 |
or object code, or execute arbitrary commands on the server. |
| 100 |
<p> |
| 101 |
The TCP server can limit clients by either checking the client |
| 102 |
address, or listening only on particular IP interfaces. However, in |
| 103 |
some circumstances an attacker can spoof connections from a false |
| 104 |
address. If such a situation apply to your network then IP-based |
| 105 |
access control is not sufficient. |
| 106 |
<p> |
| 107 |
In TCP mode there is no way to limit access by user, rather than by |
| 108 |
host. |
| 109 |
<p> |
| 110 |
IPSec or IPv6 would probably also help, but nobody has reported |
| 111 |
testing it with distcc. |
| 112 |
<p> |
| 113 |
In SSH mode the server is started by each user under their own account |
| 114 |
on the server. There is no long-lived daemon. Connections are |
| 115 |
authenticated and encrypted. Every user is allowed only the |
| 116 |
privileges that their normal account allows. |
| 117 |
<p> |
| 118 |
Because the server and client necessarily trust each other, there has |
| 119 |
been no security audit of the code that runs after a connection is |
| 120 |
established. It is possible that a hostile server could gain control |
| 121 |
of a client directly, as well as modifying the object code. |
| 122 |
<p> |
| 123 |
If the DISTCC_CMDLIST environment variable is set when invoking |
| 124 |
distccd, distccd will only execute commands from that list. |
| 125 |
(The RPM and Debian distributions of distcc set this variable |
| 126 |
via the /etc/distcc/commands.allow.sh file which is sourced by |
| 127 |
/etc/init.d/distcc). This mechanism can be used to only allow |
| 128 |
the execution of compilation commands rather than arbitrary |
| 129 |
commands. However, <b>this should not be relied on as a security |
| 130 |
measure</b>, because gcc is not secure against |
| 131 |
hostile input, and it might be possible for an attacker to gain |
| 132 |
control of the gcc process through a carefully crafted input file or |
| 133 |
command line. You should assume that anyone able to submit jobs is |
| 134 |
able to execute arbitrary operations under the account used by |
| 135 |
distccd. |
| 136 |
<p> |
| 137 |
It has been suggested that distccd should take a simple |
| 138 |
username/password authentication mechanism, but this would give a |
| 139 |
false sense of security. If you cannot trust your network, the only |
| 140 |
sensible policy is to use SSH. |
| 141 |
<p> |
| 142 |
Some people have proposed that the client should check whether a |
| 143 |
server is trustworthy by re-running compilations on a different |
| 144 |
server. This approach can be useful in some distributed-computing |
| 145 |
problem spaces such as SETI@home, but not practical for distcc. |
| 146 |
Firstly, the damage from a single compromised object file is very |
| 147 |
high, so every single file would have to be extensively checked. |
| 148 |
Secondly, the performance constraints are such that building every |
| 149 |
single file two or more times would often make distribution worthless. |
| 150 |
Thirdly there would sometimes be false alerts from minor differences |
| 151 |
in gcc patchlevel that are not visible in normal use but that do |
| 152 |
change the output file at a byte level. |
| 153 |
<p> |
| 154 |
For practical advice, see |
| 155 |
<a href="http://www.debian-administration.org/articles/157">this description of how to secure distcc using chroot and OpenVPN</a>. |
| 156 |
</tr></table> |
| 157 |
<div class="thanks">Copyright © 2002–2004, 2006 Martin Pool. |
| 158 |
<p>Send comments to <tt>distcc(at)lists.samba.org</tt> |
| 159 |
</html> |