<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">I am running some inetd firewall components that came from the legacy FWTK (<a href="http://fwtk.org">http://fwtk.org</a>) under systemd socket activation on Oracle Linux 7.4.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The author of this code has found bugs in later life.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a href="http://www.ranum.com/security/computer_security/editorials/codetools/index.html">http://www.ranum.com/security/computer_security/editorials/codetools/index.html</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">When I was using OpenBSD, I had inetd spawn these as nobody. With systemd, I go further and specify a RootDirectory, and this causes what appears to be an interesting systemd bug.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">These are the units in question:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> # cat /etc/systemd/system/yum.socket<o:p></o:p></p>
<p class="MsoNormal"> [Unit]<o:p></o:p></p>
<p class="MsoNormal"> Description=yum proxy<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> [Socket]<o:p></o:p></p>
<p class="MsoNormal"> ListenStream=5865<o:p></o:p></p>
<p class="MsoNormal"> Accept=yes<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> [Install]<o:p></o:p></p>
<p class="MsoNormal"> WantedBy=sockets.target<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> # cat /etc/systemd/system/yum@.service <o:p></o:p></p>
<p class="MsoNormal"> [Unit]<o:p></o:p></p>
<p class="MsoNormal"> Description=yum proxy<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> [Service]<o:p></o:p></p>
<p class="MsoNormal"> RootDirectory=/home/fwjail<o:p></o:p></p>
<p class="MsoNormal"> ExecStart=-/usr/local/etc/http-gw<o:p></o:p></p>
<p class="MsoNormal"> StandardInput=socket<o:p></o:p></p>
<p class="MsoNormal"> User=nobody<o:p></o:p></p>
<p class="MsoNormal"> Group=nobody<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Placing the toolkit component in /home/fwjail/usr/local/etc/http-gw, and attempting to start the socket fails:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> # systemctl start yum.socket<o:p></o:p></p>
<p class="MsoNormal"> Job for yum.socket failed. See "systemctl status yum.socket" and "journalctl -xe" for details.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, if I place any file at the corresponding location *<b>outside of the chroot</b>* the service will start normally.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> # touch /usr/local/etc/http-gw<o:p></o:p></p>
<p class="MsoNormal"> # ll /usr/local/etc/http-gw<o:p></o:p></p>
<p class="MsoNormal"> -rw-r--r--. 1 root root 0 Mar 8 11:10 /usr/local/etc/http-gw<o:p></o:p></p>
<p class="MsoNormal"> # systemctl start yum.socket<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It seems to me that systemd is (pre)checking for the program before starting the socket, and the check is not relative to the chroot/RootDirectory parameter. Is this behavior correct?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">p.s. a) I’m not using the FWTK in a security capacity at all – this is for the isolation of a QA network containing a Unisys running OS2200/EXEC 8. I have hundreds of inetd rules that I’ve ported to busybox, launched by a systemd service.
I am pumping a yum proxy back through here so I can get patches into the internal network.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">b) I have confirmed that systemd is launching the correct program, even though it is checking for the existence of the wrong one:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"># nc localhost 5865<o:p></o:p></p>
<p class="MsoNormal">GET /<o:p></o:p></p>
<p class="MsoNormal">HTTP/1.0 200 OK<o:p></o:p></p>
<p class="MsoNormal">Content-type: text/html<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><HEAD><o:p></o:p></p>
<p class="MsoNormal"><title>HTTP-GW Internal Documentation</title><o:p></o:p></p>
<p class="MsoNormal"></HEAD><o:p></o:p></p>
<p class="MsoNormal"><H1><IMG ALT="[ICON]" SRC="http://dpwints.dpw.alcoa.com:5865/http://-internal-/-http-gw-internal-/logo.gif"> HTTP-GW Internal Documentation</H1><o:p></o:p></p>
<p class="MsoNormal">The HTTP-GW is part of the <A HREF="http://dpwints.dpw.alcoa.com:5865/http://www.tis.com/">Trusted Information Systems Inc.</A><o:p></o:p></p>
<p class="MsoNormal">firewall toolkit<br>and <A HREF="http://dpwints.dpw.alcoa.com:5865/http://www.tis.com/Home/NetworkSecurity/Gauntlet/Gauntlet.html">Gauntlet (TM) product</A>.<o:p></o:p></p>
<p class="MsoNormal"><hr><o:p></o:p></p>
<p class="MsoNormal"><H2>No Server</H2><o:p></o:p></p>
<p class="MsoNormal">You have accessed the HTTP-GW and the proxy has not been able to find any<o:p></o:p></p>
<p class="MsoNormal">server information in your request and there is no default server configured<o:p></o:p></p>
<p class="MsoNormal">to hand the request off to.<o:p></o:p></p>
<p class="MsoNormal"><p><o:p></o:p></p>
<p class="MsoNormal">You may be able to get your firewall administrator to configure the firewall<o:p></o:p></p>
<p class="MsoNormal">to pass these requests off to a local HTTP server.<o:p></o:p></p>
<p class="MsoNormal"><hr><o:p></o:p></p>
<p class="MsoNormal"><A HREF="http://dpwints.dpw.alcoa.com:5865/http://-internal-/-http-gw-internal-/version.html">About HTTP-GW</A><o:p></o:p></p>
</div>
</body>
</html>