/usr/share/doc/apt-cacher-ng/html/secure.html is in apt-cacher-ng 3.1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=US-ASCII">
<title>Security</title>
<link rel="previous" href="config-serv.html">
<link rel="ToC" href="index.html">
<link rel="up" href="index.html">
<link rel="next" href="distinstructions.html">
</head>
<body>
<p><a href="config-serv.html">Previous</a> | <a href="index.html">Contents</a> | <a href="distinstructions.html">Next</a></p>
<ul>
<li><a href="#secure">Chapter 5: Security</a>
<ul>
<li><a href="#acl-bind-iface">5.1 Access control by IP interface</a></li>
<li><a href="#acl-libwrap">5.2 Access control with libwrap</a></li>
<li><a href="#acl-inetd">5.3 Access control with inetd</a></li>
<li><a href="#acl-iptables">5.4 Access control with iptables</a></li>
<li><a href="#acl-tgtports">5.5 Target port filter</a></li>
</ul></li>
</ul>
<h1><a name="secure"></a>Chapter 5: Security</h1>
<p>
Like many data storing daemons with predictable filenames, apt-cacher-ng is vulnerable to symlink attacks and similar malicious actions. Therefore, the user must make sure that the cache and log directories are writable only to the user account under which apt-cacher-ng is running.
</p>
<p>
General network access control can be established with operating system's facilities in kernel space (see below) or in user space (e.g. with inetd, see <a href="#acl-inetd">section 5.3</a>). There is also experimental built-in access filter feature which uses the TCP Wrapper library for filtering (i.e. uses the same mechanism as tcpd). See <a href="#acl-libwrap">section 5.2</a> for details.
</p>
<p>
As to the program's internal security, apt-cacher-ng has been developed with concern about a certain grade of attacks from internal users as well as from malicious external hosts. However, no guarantees can be made about the security of the program. It is recommended to run apt-cacher-ng under a dedicated system account which has no write access to any files outside of the cache and log directories. Refer to the manuals of the administration utilities of the system distribution (like start-stop-daemon) to create the required configuration.
</p>
<p>
If relaxed permissions are required, e.g. to make files group-writeable, this can be established through the appropriate use of umask command in the startup scripts of apt-cacher-ng (see <code>/etc/default/apt-cacher-ng</code>, for example) and the sticky bit on the cache directories (see <code>chmod(1)</code> manpage for details). However, write permissions should be assigned very carefully because that may make the server vulnerable to symlink attacks and like-minded activities.
</p>
<p>
The management web interface which allows execution of certain operations can be protected by HTTP credentials (username/password). The trust levels for most actions depend on their purpose. Those which should never be able to destroy important local files can be triggered by anyone if no password is set. And on the other hand, some operations are considered dangerous and can only be accessed when the admin password is configured and was entered correctly.
</p>
<h2><a name="acl-bind-iface"></a>5.1 Access control by IP interface</h2>
<p>
A simple control method for incoming connections is listening only to network interfaces which are inside a secure perimeter, e.g. belong to the local network. See <a href="howtos.html#howto-interfaces">section 8.10</a> for details on this configuration parameter. The default setting is listening to all interfaces.
</p>
<h2><a name="acl-libwrap"></a>5.2 Access control with libwrap</h2>
<p>
If the access control with operating system's ip filters is not possible, the embedded filtering might be using instead. It is turned on if the feature is included at build time and the <code>UseWrap</code> option is set to non-zero. If <code>UseWrap</code> is not set at all, it might be enabled implicitly if the hosts.allow or hosts.deny files have rules for apt-cacher-ng.
</p>
<p>
For more information about host access list creation, refer to hosts_access(5) manual page (or manual pages for hosts.allow and hosts.deny).
</p>
<p>
The libwrap filtering method has a little drawback compared to alternatives. The host checks are called in single-threaded context and can add some lag for other incoming connections.
</p>
<h2><a name="acl-inetd"></a>5.3 Access control with inetd</h2>
<p>
In some situations, access filtering by client IP or hostname might be not supported directly or there are other reasons to use inetd to wrap access to apt-cacher inetd. For this case, an inetd daemon is shipped with the package which makes the use of tcpd possible. Installation is done in following steps:
</p>
<p>
1. compile the inetd bridge tool "in.acng", if not already done (check <code>/usr/lib/apt-cacher-ng</code>).
</p>
<p>
2. Edit apt-cacher-ng's configuration (acng.conf, for example), and set a path for a new file in a writable directory, like this:
</p>
<p>
<code>SocketPath:/var/run/apt-cacher-ng/socket</code>
</p>
<p>
3. Edit /etc/inetd.conf and add following line with appropriate path names and TCP port:
</p>
<pre><code>3143 stream tcp nowait user /usr/sbin/tcpd
/usr/local/sbin/in.acng /var/run/apt-cacher-ng/socket
</code></pre>
<p>
4. Edit hosts.allow and other files to configure ACLs for port 3143. See tcpd(8) and related manpages for further details.
</p>
<p>
5. Configure clients to use the alternative port (3143 in the example above).
</p>
<h2><a name="acl-iptables"></a>5.4 Access control with iptables</h2>
<p>
Looking at performance, the most efficient way to estables access control by source IP is the use of system's native mechanisms. For the Linux kernel, it can be created with iptables rules like in the following example, usually stored in system's firewall setup script (or any init script like <code>/etc/rc.local</code>):
</p>
<pre><code>iptables -A INPUT -p tcp --dport 3142 --source 127.0.0.0/8 -j ACCEPT
iptables -A INPUT -p tcp --dport 3142 --source 192.168.0.0/16 -j ACCEPT
iptables -A INPUT -p tcp --dport 3142 -j REJECT --reject-with tcp-reset
</code></pre>
<h2><a name="acl-tgtports"></a>5.5 Target port filter</h2>
<p>
In the default configuration, <em>apt-cacher-ng</em> restricts the choice of the target port on the remote mirror to the default HTTP port (80). This is intended to prevent creation of HTTP tunnels and similar malicious user activities.
</p>
<p>
Cache administrator can define an own list of allowed ports by setting them as (space separated) list with the AllowUserPorts configuration directive.
</p>
<p>
Alternatively, access to custom TCP ports can be established through custom remapping specification.
</p>
<hr><address>Comments to <a href='mailto:blade@debian.org'>blade@debian.org</a>
<br>
[Eduard Bloch, Sun, 19 Apr 2015 10:25:49 +0200]</address></body>
</html>
|