####################################################################### Luigi Auriemma Applicazione: libextractor http://gnunet.org/libextractor/ Versioni: <= 0.5.13 (rev 2832) Piattaforme: *nix, *BSD, Windows ed altre Bugs: A] heap overflow in asfextractor B] heap overflow in qtextractor Exploitation: locale Data: 17 May 2006 Autore: Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org ####################################################################### 1) Introduzione 2) Bugs 3) The Code 4) Fix ####################################################################### =============== 1) Introduzione =============== libextractor e' una libreria che permette la ricerca di meta-dati all'interno di diversi tipi di files. E' usata in diversi programmi ed e' un requisito fondamentale per GnuNET (http://gnunet.org). ####################################################################### ======= 2) Bugs ======= -------------------------------- A] heap overflow in asfextractor -------------------------------- La struttura demux_asf_t e' allocata quando il plugin e' inizializzato, successivamente viene effettuata una chiamata alla funzione asf_read_header dove viene letto tutto l'header del file arrivando alla gestione (a seconda del file) prima di GUID_ASF_STREAM_PROPERTIES e poi di CODEC_TYPE_AUDIO. Qui abbiamo la copia arbitraria di una quantita' di dati, specificata nel numero a 32 bit chiamato total_size, dal file ASF al buffer wavex di 1024*2 bytes. Il valore contenuto in total_size e' letto dallo stesso file e non vengono effettuati controlli su di esso quindi e' possibile causare un heap overflow. Da src/plugins/asfextractor.c: static int asf_read_header(demux_asf_t *this) { ... total_size = get_le32(this); stream_data_size = get_le32(this); stream_id = get_le16(this); /* stream id */ get_le32(this); if (type == CODEC_TYPE_AUDIO) { ext_uint8_t buffer[6]; readBuf (this, (ext_uint8_t *) this->wavex, total_size); ... ------------------------------- B] heap overflow in qtextractor ------------------------------- Un heap overflow esiste anche nel plugin che gestisce i files QT/MOV. Il problema si trova nella funzione parse_trak_atom ed e' causato dall'allocazione di un buffer utilizzando una specifica quantita' di memoria scelta dall'attacker sul quale viene poi chiamato memcpy utilizzando una quantita' di dati specificata sempre dallo stesso file. Da src/plugins/qtextractor.c: static qt_error parse_trak_atom (qt_trak *trak, unsigned char *trak_atom) { ... trak->stsd_size = current_atom_size; trak->stsd = realloc (trak->stsd, current_atom_size); memset (trak->stsd, 0, trak->stsd_size); /* awful, awful hack to support a certain type of stsd atom that * contains more than 1 video description atom */ if (BE_32(&trak_atom[i + 8]) == 1) { /* normal case */ memcpy (trak->stsd, &trak_atom[i], current_atom_size); hack_adjust = 0; } else { /* pathological case; take this route until a more definite * solution is found: jump over the first atom video * description atom */ /* copy the first 12 bytes since those remain the same */ memcpy (trak->stsd, &trak_atom[i], 12); /* skip to the second atom and copy it */ hack_adjust = BE_32(&trak_atom[i + 0x0C]); memcpy(trak->stsd + 12, &trak_atom[i + 0x0C + hack_adjust], BE_32(&trak_atom[i + 0x0C + hack_adjust])); ... ####################################################################### =========== 3) The Code =========== http://aluigi.org/poc/libextho.zip ####################################################################### ====== 4) Fix ====== Il bug nel plugin ASF e' stato corretto nella revision 2827 mentre quello in QT nella 2833. #######################################################################