####################################################################### Luigi Auriemma Applicazione: BomberClone http://bomberclone.de Versioni: <= 0.11.6 e CVS corrente Piattaforme: Windows, *nix, *BSD ed altre Bugs: A] memcpy crash in rscache_add B] information disclosure in send_pkg C] simple error message termination Exploitation: remote, contro server Data: 30 Jul 2006 Autore: Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org ####################################################################### 1) Introduzione 2) Bugs 3) The Code 4) Fix ####################################################################### =============== 1) Introduzione =============== BomberClone e' un clone open source di AtomicBomberMan con supporto al multiplayer. Da notare che il gioco e' ancora in una fase di beta e non esiste un master server per indicizzare i servers online quindi questi bugs vanno considerati una "curiosita'" e niente piu'. ####################################################################### ======= 2) Bugs ======= ------------------------------ A] memcpy crash in rscache_add ------------------------------ La funzione send_pkg utilizzata nel gioco supporta una funzione di caching automatico (rscache_add) per riinviare lo stesso pacchetto se non viene ricevuto l'acknowledge. rscache_add copia semplicemente il pacchetto in output che si vuole tenere in cache in un buffer globale ma ci sono alcuni errori in queste funzioni (NULLed od invalido resend_cache.entry->packet, big endian check bypass ed altri) che portano ad un crash. Da pkgcache.c: int rscache_add (_net_addr * addr, struct pkg *packet) { int newlen; /* maybe we forgot to check here something? i don't know but it seems * that i forgot to calculate the packetsize into this. * (i'll add the packet len to this calculation) */ if (resend_cache.fill + sizeof (struct _rscache_entry) + packet->h.len > PKG_RESENDCACHE_SIZE) return -1; rscache_setpointer (resend_cache.fill); resend_cache.entry->retry = 0; resend_cache.entry->timestamp = timestamp; memcpy (&resend_cache.entry->addr, addr, sizeof (_net_addr)); memcpy (&resend_cache.entry->packet, packet, NTOH16 (packet->h.len)); newlen = resend_cache.fill + rscache_getcurlen (); resend_cache.fill = newlen; return 0; }; ------------------------------------- B] information disclosure in send_pkg ------------------------------------- La funzione send_pkg viene utilizzata per l'invio dei pacchetti. In alcune delle funzioni che gestiscono i dati in entrata, come do_gameinfo, il campo len (un numero a 16 bit utilizzato per specificare la grandezza del pacchetto) non viene resettato e quindi viene inviato un pacchetto contenente la quantita' di dati specificata dal valore len ricevuto nel pacchetto originale. Durante i miei test e' stato possibile catturare alcune informazioni utili come parti della stringa di environment. Da packets.c: void send_pkg (struct pkg *packet, _net_addr * addr) { /* check if the packet would be send to * an AI_Player, so ignore it. */ if ((addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS) && PS_IS_aiplayer (players[addr->pl_nr].state)) return; /* set the id for the packet and the network flags * the id is needed for the inpkg index to check for * double reached packets */ packet->h.id = HTON16 (pkg_lastid++); if (bman.net_ai_family != PF_INET) packet->h.flags = packet->h.flags | PKGF_ipv6; udp_send (bman.sock, (char *) packet, NTOH16 (packet->h.len), &addr->sAddr, bman.net_ai_family); /* if PKGF_ackreq is set add the packet to the resendcache * so we can resend it if no PKF_ackreq returned for the packet. */ if (packet->h.flags & PKGF_ackreq) { if (rscache_add (addr, packet) == -1) d_printf ("resend_cache overrun.... packet throw away.\n"); } }; ----------------------------------- C] simple error message termination ----------------------------------- Il pacchetto d'errore utilizzato per trasmettere messaggi di errore ai clients e kickarli puo' essere utilizzato anche contro allo stesso server terminandolo immediatamente. ####################################################################### =========== 3) The Code =========== http://aluigi.org/poc/bcloneboom.zip ####################################################################### ====== 4) Fix ====== Una patch verra' rilasciata a breve. #######################################################################