centos 6
buffer weakness #28

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Does not check for buffer overflows.

File Name:

shadow-4.1.5.1/contrib/adduser-old.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 6 buffer weakness.

 				}
			if (group==0){	/* You're not allowed to make root group users! */
				printf("Creation of root group users not allowed (must be done by hand)\n");
				group=DEFAULT_GROUP;
				bad=1;
			};
		} while(bad);


		fflush(stdin);
      
		printf("\nIf home dir ends with a / then [%s] will be appended to it\n",uname);
		printf("Home Directory [%s/%s]: ",DEFAULT_HOME,uname);
		fflush(stdout);
		gets(dir);
		if (!strlen(dir)) { /* hit return */
			sprintf(dir,"%s/%s",DEFAULT_HOME,uname);
			fflush(stdin);
		} else
			if (dir[strlen(dir)-1]=='/')
				sprintf(dir+strlen(dir),"%s",uname);

		printf("\nShell [%s]: ",DEFAULT_SHELL);
		fflush(stdout);
		gets(shell);
		if (!strlen(shell))
			sprintf(shell,"%s",DEFAULT_SHELL);
      
		printf("\nMin. Password Change Days [0]: ");
		gets(foo);
		min_pass=atoi(foo);
            
		printf("Max. Password Change Days [%d]: ",DEFAULT_MAX_PASS);
		gets(foo);
		if (strlen(foo) > 1)
			max_pass = atoi(foo);
		else
			max_pass = DEFAULT_MAX_PASS;
            
		printf("Password Warning Days [%d]: ",DEFAULT_WARN_PASS);
		gets(foo);
		warn_pass = atoi(foo);
		if (warn_pass==0)
			warn_pass = DEFAULT_WARN_PASS;
            
		printf("Days after Password Expiry for Account Locking [%d]: ",DEFAULT_USER_DIE);
		gets(foo);
		user_die = atoi(foo);
		if (user_die == 0)
			user_die = DEFAULT_USER_DIE; 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.