diff options
author | wpaul <wpaul@FreeBSD.org> | 1996-09-30 22:27:00 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1996-09-30 22:27:00 +0000 |
commit | c8132b2e31d6c5dc8067b94e551d8618819697ff (patch) | |
tree | c9c4f461f68c7e6cecce810e8a73c28642451623 /usr.sbin/ypserv | |
parent | 7706e782e683d8d989a649d386f2b5c12ccd2768 (diff) | |
download | FreeBSD-src-c8132b2e31d6c5dc8067b94e551d8618819697ff.zip FreeBSD-src-c8132b2e31d6c5dc8067b94e551d8618819697ff.tar.gz |
Close a potential security hole: if yp_access() is passed a map name,
have it check to see that it doesn't contain any '/' characters. This
prevents possible silliness like ypcat "../../../kernel". We already
test the domain name for this in yp_validdomain(), and ypserv itself
tests the map name in yp_open_db(), but it doesn't hurt to be paranoid
and test for it in the generic access routine too. rpc.ypxfrd does not
test the map name for slashes, but it does call yp_access() with the
map name, so this removes a potential vulnerability from there.
Also make the tests for IPPORT_RESERVED a little more selective: make
sure it trips when map == master.passwd.*, prog == YPPROC and proc ==
YPPROC_XFR, and prog == YPXFRD_FREEBSD_PROG and proc == YPXFRD_GETMAP.
Also use IPPORT_RESERVED instead of hard-coded value.
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r-- | usr.sbin/ypserv/yp_access.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.sbin/ypserv/yp_access.c b/usr.sbin/ypserv/yp_access.c index ef7fc56..5111788 100644 --- a/usr.sbin/ypserv/yp_access.c +++ b/usr.sbin/ypserv/yp_access.c @@ -35,6 +35,7 @@ #include <rpc/rpc.h> #include <rpcsvc/yp.h> #include <rpcsvc/yppasswd.h> +#include <rpcsvc/ypxfrd.h> #include <sys/types.h> #include <limits.h> #include <db.h> @@ -52,7 +53,7 @@ #endif #ifndef lint -static const char rcsid[] = "$Id: yp_access.c,v 1.2 1996/05/01 02:39:54 wpaul Exp $"; +static const char rcsid[] = "$Id: yp_access.c,v 1.9 1996/06/05 02:01:29 wpaul Exp $"; #endif extern int debug; @@ -242,10 +243,20 @@ int yp_access(map, rqstp) /* Check the map name if one was supplied. */ if (map != NULL) { + if (strchr(map, '/')) { + yp_error("embedded slash in map name \"%s\" -- \ +possible spoof attempt from %s:%d", + map, inet_ntoa(rqhost->sin_addr), + ntohs(rqhost->sin_port)); + } if ((strstr(map, "master.passwd.") || - rqstp->rq_proc == YPPROC_XFR) && - ntohs(rqhost->sin_port) > 1023) { - yp_error("Access to %s denied -- client not privileged", map); + (rqstp->rq_prog == YPPROG && + rqstp->rq_proc == YPPROC_XFR) || + (rqstp->rq_prog == YPXFRD_FREEBSD_PROG && + rqstp->rq_proc == YPXFRD_GETMAP)) && + ntohs(rqhost->sin_port) >= IPPORT_RESERVED) { + yp_error("Access to %s denied -- client %s:%d \ +not privileged", map, inet_ntoa(rqhost->sin_addr), ntohs(rqhost->sin_port)); return(1); } } |