centos 7
access weakness #34

1

Weakness Breakdown


Definition:

An access weakness occurs when software does not properly implement permissions that could have unintended consequences if exploited by malicious actors. An example of this weakness is when a default username and password are set by the developer but do not get changed by the system administrator.

Warning code(s):

Ensure that umask is given most restrictive possible setting.

File Name:

sssd-1.16.2/src/providers/krb5/krb5_ccache.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 7 access weakness.

         goto done;
    }

    ret = find_ccdir_parent_data(tmp_ctx, ccdirname, &parent_stat,
                                 &missing_parents);
    if (ret != EOK) {
        DEBUG(SSSDBG_MINOR_FAILURE,
              "find_ccdir_parent_data failed.\n");
        goto done;
    }

    ret = check_parent_stat(&parent_stat, uid);
    if (ret != EOK) {
        DEBUG(SSSDBG_FATAL_FAILURE,
              "Check the ownership and permissions of krb5_ccachedir: [%s].\n",
              ccdirname);
        goto done;
    }

    DLIST_FOR_EACH(li, missing_parents) {
        DEBUG(SSSDBG_TRACE_INTERNAL,
              "Creating directory [%s].\n", li->s);
        new_dir_mode = 0700;

        old_umask = umask(0000);
        ret = mkdir(li->s, new_dir_mode);
        umask(old_umask);
        if (ret != EOK) {
            ret = errno;
            DEBUG(SSSDBG_MINOR_FAILURE,
                  "mkdir [%s] failed: [%d][%s].\n", li->s, ret,
                   strerror(ret));
            goto done;
        }
        ret = chown(li->s, uid, gid);
        if (ret != EOK) {
            ret = errno;
            DEBUG(SSSDBG_MINOR_FAILURE,
                  "chown failed [%d][%s].\n", ret, strerror(ret));
            goto done;
        }
    }

    ret = EOK;

done:
    talloc_free(tmp_ctx);
    return ret;
}
 

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.