####################################################################### Luigi Auriemma Applicazione: libmusicbrainz http://musicbrainz.org/doc/libmusicbrainz Versioni: <= 2.1.2 e <= SVN 8406 (SVN corrente) Piattaforme: Windows, *nix, *BSD, Mac ed altre Bugs: A] buffer-overflow in MBHttp::Download B] various buffer-overflows in rdfparse.c Exploitation: remoto Data: 13 Aug 2006 Autore: Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org ####################################################################### 1) Introduction 2) Bugs 3) The Code 4) Fix ####################################################################### =============== 1) Introduction =============== libmusicbrainz (aka mb_client) e' una libreria usata in diversi programmi multimediali per interrogare i servers MusicBrainz. ####################################################################### ======= 2) Bugs ======= -------------------------------------- A] buffer-overflow in MBHttp::Download -------------------------------------- Un web server MusicBrainz malevolo puo' sfruttare un buffer-overflow nella funzione Download della libreria attraverso un risposta contenente un URL di redirect molto grande. Questo bug puo' essere sfruttato anche in altri modi da locale in quanto il problema e' nelle istruzioni che gestiscono l'hostname nell'URL. Da lib/http.cpp: Error MBHttp::Download(const string &url, const string &xml, bool fileDownload) { Error result = kError_InvalidParam; char hostname[kMaxHostNameLen + 1]; char targethostname[kMaxHostNameLen + 1]; char proxyname[kMaxURLLen + 1]; ... const char *ptr; hostname[0] = 0; numFields = sscanf(url.c_str(), "http://%[^:/]:%hu", hostname, &port); strcpy(targethostname, hostname); ptr = strchr(url.c_str() + 7, '/'); file = string(ptr ? ptr : ""); ... // 3xx: Redirection - Further action must be taken in order to // complete the request case '3': { char* cp = strstr(buffer, "Location:"); //int32 length; if(cp) { cp += 9; if(*cp == 0x20) cp++; char *end; for(end = cp; end < buffer + total; end++) if(*end=='\r' || *end == '\n') break; *end = 0x00; ... result = Download(string(cp), xml, fileDownload); } ... ----------------------------------------- B] various buffer-overflows in rdfparse.c ----------------------------------------- Le istruzioni in lib/rdfparse.c che analizzano i dati RDF ricevuti dal server sono vulnerabili a diversi buffer-overflow sfruttabili tramite degli URL molto grandi (situati ad esempio nel campo rdf:resource) che vengono copiati in buffers di 256 bytes. Per esempio in parse_uri il parametro len contenente la grandezza del buffer (uno dei buffers base_buffer o reference_buffer di 256 bytes dichiarati in resolve_uri_reference) non viene controllato quindi un URI molto grande causera' un buffer-overflow. La stessa funzione che chiama parse_uri e' affetta da altri buffer overflow per la medesima ragione, il valore di length non viene gestito. Stesso problema per resolve_id e diverse altre funzioni. ####################################################################### =========== 3) The Code =========== http://aluigi.org/poc/brainzbof.zip usage examples: A] nc -l -p 80 -v -v -n < brainzbof_a.txt B] nc -l -p 80 -v -v -n < brainzbof_b.txt ####################################################################### ====== 4) Fix ====== Una nuova versione sara' rilasciata a breve #######################################################################