Changeset 5154:3d1d7f6cf693

Show
Ignore:
Timestamp:
2007-04-02 15:20:58 (20 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
mutt-1-4-stable
Message:

Validate msgid in APOP authentication. Closes #2846

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pop_auth.c

    r2766 r5154  
    185185    return POP_A_UNAVAIL; 
    186186 
     187  if (rfc822_valid_msgid (pop_data->timestamp) < 0) 
     188  { 
     189    mutt_error _("POP timestamp is invalid!"); 
     190    mutt_sleep (2); 
     191    return POP_A_UNAVAIL; 
     192  } 
     193 
    187194  mutt_message _("Authenticating (APOP)..."); 
    188195 
  • rfc822.c

    r2766 r5154  
    765765} 
    766766 
     767/* incomplete. Only used to thwart the APOP MD5 attack (#2846). */ 
     768int rfc822_valid_msgid (const char *msgid) 
     769{ 
     770  /* msg-id         = "<" addr-spec ">" 
     771   * addr-spec      = local-part "@" domain 
     772   * local-part     = word *("." word) 
     773   * word           = atom / quoted-string 
     774   * atom           = 1*<any CHAR except specials, SPACE and CTLs> 
     775   * CHAR           = ( 0.-127. ) 
     776   * specials       = "(" / ")" / "<" / ">" / "@" 
     777                    / "," / ";" / ":" / "\" / <"> 
     778                    / "." / "[" / "]" 
     779   * SPACE          = ( 32. ) 
     780   * CTLS           = ( 0.-31., 127.) 
     781   * quoted-string  = <"> *(qtext/quoted-pair) <"> 
     782   * qtext          = <any CHAR except <">, "\" and CR> 
     783   * CR             = ( 13. ) 
     784   * quoted-pair    = "\" CHAR 
     785   * domain         = sub-domain *("." sub-domain) 
     786   * sub-domain     = domain-ref / domain-literal 
     787   * domain-ref     = atom 
     788   * domain-literal = "[" *(dtext / quoted-pair) "]" 
     789   */ 
     790 
     791  char* dom; 
     792  unsigned int l, i; 
     793 
     794  if (!msgid || !*msgid) 
     795    return -1; 
     796 
     797  l = mutt_strlen (msgid); 
     798  if (l < 5) /* <atom@atom> */ 
     799    return -1; 
     800  if (msgid[0] != '<' || msgid[l-1] != '>') 
     801    return -1; 
     802  if (!(dom = strrchr (msgid, '@'))) 
     803    return -1; 
     804 
     805  /* TODO: complete parser */ 
     806  for (i = 0; i < l; i++) 
     807    if (msgid[i] > 127) 
     808      return -1; 
     809 
     810  return 0; 
     811} 
     812 
    767813#ifdef TESTING 
    768814int safe_free (void **p) 
  • rfc822.h

    r2766 r5154  
    5656void rfc822_free_address (ADDRESS **addr); 
    5757void rfc822_cat (char *, size_t, const char *, const char *); 
     58int rfc822_valid_msgid (const char *msgid); 
    5859 
    5960extern int RFC822Error;