alpine 3.6
access weakness #78

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:

libetpan/src/libetpan-1.7.2/tests/fetch-attachment.c

Context:

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

 #include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <libetpan/libetpan.h>

#include "option-parser.h"
#include "readmsg-common.h"

/* write content to the given filename */

static int etpan_write_data(char * filename, char * data, size_t len)
{
  size_t write_len;
  FILE * f;
  int res;
  mode_t old_umask;
  
  old_umask = umask(0077);
  f = fopen(filename, "wb");
  umask(old_umask);
  if (f == NULL) {
    res = ERROR_FILE;
    goto err;
  }

  write_len = fwrite(data, 1, len, f);
  if (write_len < len) {
    res = ERROR_FILE;
    goto close;
  }

  fclose(f);

  return NO_ERROR;

 close:
  fclose(f);
 err:
  return res;
}


/* save attachment */

static int save_mime_content(mailmessage * msg_info,
    struct mailmime * mime_part)
{ 

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.