alpine 3.9
format weakness #5

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always 0-terminate.

File Name:

apache-mod-auth-kerb/src/mod_auth_kerb-5.4/src/mod_auth_kerb.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.9 format weakness.

 	((kerb_auth_config *)rec)->krb_method_gssapi = 1;
#endif
#ifdef KRB4
	((kerb_auth_config *)rec)->krb_method_k4pass = 1;
#endif
	return rec;
}

static const char*
krb5_save_realms(cmd_parms *cmd, void *vsec, const char *arg)
{
   kerb_auth_config *sec = (kerb_auth_config *) vsec;
   sec->krb_auth_realms= apr_pstrdup(cmd->pool, arg);
   return NULL;
}

static void
log_rerror(const char *file, int line, int level, int status,
           const request_rec *r, const char *fmt, ...)
{
   char errstr[1024];
   va_list ap;

   va_start(ap, fmt);
   vsnprintf(errstr, sizeof(errstr), fmt, ap);
   va_end(ap);

   
#ifdef STANDARD20_MODULE_STUFF
   ap_log_rerror(file, line, level | APLOG_NOERRNO, status, r, "%s", errstr);
#else
   ap_log_rerror(file, line, level | APLOG_NOERRNO, r, "%s", errstr);
#endif
}

#ifdef KRB4
/*************************************************************************** 
 Username/Password Validation for Krb4
 ***************************************************************************/
static int
verify_krb4_user(request_rec *r, const char *name, const char *instance,
                 const char *realm, const char *password, const char *linstance, const char *srvtab, int krb_verify_kdc)
{
   int ret;
   char *phost;
   unsigned long addr;
   struct hostent *hp;
   const char *hostname;
   KTEXT_ST ticket;
   AUTH_DAT authdata; 

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.