ports/83434: tomcat ports give the wrong ownership to their installed executables
jan.grant at bristol.ac.uk
Thu Jul 14 07:20:17 UTC 2005
>Synopsis: tomcat ports give the wrong ownership to their installed executables
>Arrival-Date: Thu Jul 14 07:20:16 GMT 2005
>Originator: jan grant
University of Bristol
FreeBSD tribble.ilrt.bris.ac.uk 5.4-STABLE FreeBSD 5.4-STABLE #0: Thu Jun 16 13:59:43 BST 2005 cmjg at tribble.ilrt.bris.ac.uk:/external/usr.obj/usr/src/sys/JAN i386
The tomcat processes, as installed, run as the user/group www:www. This is fine. However, looking at the ports (all of the tomcat ports, and this problem extends to other java ports too), the install scripts are overly generous in giving away installed files to www:www.
This is problematic because it means that the process (and, in the absence of a properly-configured policy file - note jboss ports install a policy file, but it permits "anything") can write to its own executables - including the "tomcat50ctl" file. Thus, malicious webapps can "leak" out and corrupt their container. It's not really an example of "defense in depth".
Additionally, you're at risk from any other process running under www:www - for example, a CGI script.
Install any jakarta-tomcat, or jboss (or possibly other, that's as far as I've checked) port.
The first permission problem is pretty straightforward, and can be fixed by only giving the tomcat user (www:www) ownership to the webapps, work, temp and logs subdirectories - everything else can be owned by root.
When it comes to it, a slightly smarter tomcat*ctl program can be made suid root rather than sugid www:www; capturing the tomcat process PID isn't overly difficult. Fixing the "executable" parts of the tomcat, jboss installations to be immutable to non-root users would be a great start however.
More information about the freebsd-ports-bugs