| Summary: | Apache's suEXEC wrapper doesn't enforce user limits | ||
|---|---|---|---|
| Product: | Ports & Packages | Reporter: | Andy Farkas <andyf> |
| Component: | Individual Port(s) | Assignee: | Andrey A. Chernov <ache> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | CC: | ache |
| Priority: | Normal | ||
| Version: | Latest | ||
| Hardware: | Any | ||
| OS: | Any | ||
Responsible Changed From-To: freebsd-ports->ache Over to maintainer State Changed From-To: open->closed Alternative patch committed. |
Apache's suEXEC wrapper doesn't enforce user limits. Users may exhaust various system resources, even though resource limits have been properly set. Fix: This patch is for Apache-1.3.9: #include <stdarg.h> @@ -250,6 +251,7 @@ char *cmd; /* command to be executed */ char cwd[AP_MAXPATH]; /* current working directory */ char dwd[AP_MAXPATH]; /* docroot working directory */ + login_cap_t *lc; /* user resource limits */ struct passwd *pw; /* password entry holder */ struct group *gr; /* group entry holder */ struct stat dir_info; /* directory info holder */ @@ -401,6 +403,19 @@ if ((gid == 0) || (gid < GID_MIN)) { log_err("cannot run as forbidden gid (%d/%s)\n", gid, cmd); exit(108); + } + + /* + * Apply user resource limits based on login class. + */ + if ((lc = login_getclassbyname(pw->pw_class, pw)) == NULL) { + log_err("failed to login_getclassbyname()\n"); + exit(109); + } + + if ((setusercontext(lc, pw, uid, LOGIN_SETRESOURCES)) != 0) { + log_err("failed to setusercontext()\n"); + exit(109); } /*--6pyT2LNcUxA9CZDc6GQPJgXnPjG7GYOzXdv8xFk0LYpg7TTW Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" --- suexec.c.orig Tue Jun 22 10:51:41 1999 +++ suexec.c Mon Sep 6 21:47:33 1999 @@ -75,6 +75,7 @@ #include <sys/param.h> #include <sys/stat.h> #include <sys/types.h> +#include <login_cap.h> How-To-Repeat: Enable the suEXEC wrapper for user CGI scripts and expect the system to be 'more stable'. Weep as the system grounds to a halt when user 'bob' uploads his "for(;;)" code and tells his mates to "click here as many times as you can!". Note that user bob has maxproc set to 2 and cputime to 60 secs.