alpine 3.7
misc weakness #426

4

Weakness Breakdown


Definition:

The software specifies permissions for a security-critical resource in a way that allows the resource to be read or modified by unintended actors.

Warning code(s):

This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data.

File Name:

krb5/src/krb5-1.15.4/src/clients/kpasswd/ksetpwd.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.7 misc weakness.

     char user[512];
    char * password = NULL;
    int result;

    user[0] = 0;
    result = -1;

    for(;;)
    {
        while( user[0] == 0 )
        {
            int userlen;
            printf( "Username: ");
            fflush(stdout);
            if( fgets( user, sizeof(user), stdin ) == NULL )
                return -1;
            userlen = strlen( user);
            if( userlen < 2 )
                continue;
            user[userlen-1] = 0;    /* get rid of the newline */
            break;
        }
        {
            kbrccache_t usercontext;
            password = getpass( "Password: ");
            if( ! password )
                return -1;
            result = 0;
            usercontext = userinitcontext( user, NULL, password, NULL, 1, &result );
            if( usercontext )
                break;
        }
    }
    return result;
}

int main( int argc, char ** argv )
{
    char * new_password;
    char * new_password2;
    krb5_context    kcontext;
    krb5_error_code kerr;
    krb5_principal  target_principal;


    if( argc < 2 )
    {
        fprintf( stderr, "Usage: setpass user@REALM\n");
        exit(1);
    } 

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.