Bug 4867 - incorrect NIS netgroup information may be used for passwd entries
Summary: incorrect NIS netgroup information may be used for passwd entries
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1997-10-27 20:50 UTC by kwhite
Modified: 1997-11-16 03:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kwhite 1997-10-27 20:50:01 UTC
the innetgr() helper routine _listmatch() in
/usr/src/lib/libc/gen/getnetgrent.c returns false positives
for netgroups that match the regular expression '^.*group$'
(substitute for group).  This allows for "surprising" entries in the
password file to be used.

For example, if your password file contains entries like this:

+@baduser:::::::::/bin/abusemsg
+@user:::::::::/bin/sh

a user in the "user" netgroup *may* get the "baduser" shell.
(depends on the order of the user's entry in netgroups.byuser)

Fix: 

The following _listmatch() routine may work better:

static int _listmatch(list, group, len)
char *list, *group;
int len;
{
        char *ptr = list;
        int glen = strlen(group);
 
        while ( (ptr = strstr(ptr, group)) ) {
 
                ptr += glen; 
                if ((ptr-glen == list || ptr[-glen-1] == ',') &&
                        (*ptr == ',' || *ptr == '\0'))
                        return(1);
        }

        return(0);
}
How-To-Repeat: create NIS users a and b
place user a in netgroup baduser
place user b in netgroup user
Add the above two lines to the password file
Notice how user b is treated like a "baduser"
Comment 1 Bill Paul freebsd_committer freebsd_triage 1997-11-16 03:04:46 UTC
State Changed
From-To: open->closed


Fixed in rev 1.23 (in -current) and 1.17.2.4 (in RELENG_2_2) of 
getnetgrent.c. I rewrite _listmatch() so that it no longer returns 
false matches.