####################################################################### Luigi Auriemma Applicazione: Outgun http://koti.mbnet.fi/outgun/ Versioni: <= 1.0.3 bot 2 Piattaforme: Windows, *nix, *BSD ed altre Bugs: A] data_file_request buffer-overflow B] exception with big data C] invalid memory access in messages handling D] harmless buffer-overflow on a global variable in changeRegistration Exploitation: remoto, contro server Data: 12 May 2006 Autore: Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org ####################################################################### 1) Introduzione 2) Bugs 3) The Code 4) Fix ####################################################################### =============== 1) Introduzione =============== Outgun e' un gioco 2D open source di tipo capture-the-flag. Supporta sia per il multiplayer in LAN che via Internet tramite un master server centralizzato. ####################################################################### ======= 2) Bugs ======= -------------------------------------------- A] data_file_request command buffer-overflow -------------------------------------------- Il gioco supporta lo scaricamento dei file delle mappe direttamente dal server nel quale i clients vogliono giocare. La richiesta per effettuare tale operazione e' composta dal comando data_file_request e da due stringhe di testo per il tipo ed il nome del file richiesto. I buffer nei quali il server immagazzina queste due stringhe hanno una grandezza di 64 e 256 bytes e la funzione readString non effettua controlli sulla lunghezza del buffer di destinazione durante la copia. Da src/servnet.cpp: void ServerNetworking::incoming_client_data(int id, char *data, int length) { ... else if (code == data_file_request) { char ftype[64]; char fname[256]; readString(msg, count, ftype); readString(msg, count, fname); ... -------------------------- B] exception with big data -------------------------- Le funzioni leetnet usate nel gioco per gestire i pacchetti attivano automaticamente un'eccezione (throw) se viene ricevuto un dato con dimensione maggiore di 512 (DATA_BUF_SIZE) bytes. L'effetto e' l'immediata interruzione del gioco. Da src/leetnet/rudp.cpp: class data_ci : public data_c { public: //allocated length, used length int alen, ulen; //data buffer char buf[DATA_BUF_SIZE]; //extend buffer to fit additional len void extend(int len) { if (len + ulen > DATA_BUF_SIZE) { throw 66677; } ... --------------------------------------------- C] invalid memory access in messages handling --------------------------------------------- Le funzioni leetnet supportano un massimo di 64 messaggi in ogni pacchetto ma non viene fatto alcun controllo per evitare la lettura della memoria non allocata dopo tale pacchetto. Da src/leetnet/rudp.cpp: virtual char* process_incoming_packet(int *size, bool *special) { ... NLulong msgid; NLshort msgsize; for (i=0; iadd_reliable(msgid, (udp_data + count), msgsize); //data } ... ---------------------------------------------------------------------- D] harmless buffer-overflow on a global variable in changeRegistration ---------------------------------------------------------------------- changeRegistration e' una funzione per gestire il cambiamento delle informazioni di registrazione dei clients. Questa funziona usa strcpy per copiare il token del client in un buffer di 64 bytes situato in un array globale contenente tutte le informazioni dei clients. Durante i miei test (limitati dal problema descritto nel bug B) non e' stato possibile sfruttare questo bug per crashare il server ma e' stato possibile soltanto modificare alcune delle informazioni degli altri giocatori nel server. Da src/servernet.cpp: bool Server::changeRegistration(int id, const string& token) { const int intoken = atoi(token.c_str()); if (intoken == client[id].intoken) return false; // v0.4.9 FIX : IF HAD previous token have/valid, then FLUSH his stats network.client_report_status(id); strcpy(client[id].token, token.c_str()); ... ####################################################################### =========== 3) The Code =========== http://aluigi.org/poc/outgunx.zip ####################################################################### ====== 4) Fix ====== Alcuni dei bugs verranno corretti nella prossima "bot" release. #######################################################################