alpine 3.6
access weakness #479

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:

kyua/src/kyua-0.13/utils/process/isolation_test.cpp

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 access weakness.

 }


/// Subprocess that validates that it has become the leader of a process group.
///
/// \post Exits with success if the process lives in its own process group;
/// failure otherwise.
static void
check_process_group(void)
{
    process::isolate_child(none, fs::path("."));
    std::exit(::getpgid(::getpid()) == ::getpid() ?
              EXIT_SUCCESS : EXIT_FAILURE);
}


/// Subprocess that validates that the umask has been reset.
///
/// \post Exits with success if the umask matches the expected value; failure
/// otherwise.
static void
check_umask(void)
{
    process::isolate_child(none, fs::path("."));
    std::exit(::umask(0) == 0022 ? EXIT_SUCCESS : EXIT_FAILURE);
}


}  // anonymous namespace


ATF_TEST_CASE_WITHOUT_HEAD(isolate_child__clean_environment);
ATF_TEST_CASE_BODY(isolate_child__clean_environment)
{
    utils::setenv("HOME", "/non-existent/directory");
    utils::setenv("TMPDIR", "/non-existent/directory");
    utils::setenv("LANG", "C");
    utils::setenv("LC_ALL", "C");
    utils::setenv("LC_COLLATE", "C");
    utils::setenv("LC_CTYPE", "C");
    utils::setenv("LC_MESSAGES", "C");
    utils::setenv("LC_MONETARY", "C");
    utils::setenv("LC_NUMERIC", "C");
    utils::setenv("LC_TIME", "C");
    utils::setenv("LEAVE_ME_ALONE", "kill-some-day");
    utils::setenv("TZ", "EST+5");

    const process::status status = fork_and_run(check_clean_environment);
    ATF_REQUIRE(status.exited());
    ATF_REQUIRE_EQ(EXIT_SUCCESS, status.exitstatus()); 

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.