Multiple vulnerabilities in Outgun 1.0.3 bot 2




#######################################################################

Luigi Auriemma

Application: Outgun
http://koti.mbnet.fi/outgun/
Versions: <= 1.0.3 bot 2
Platforms: Windows, *nix, *BSD and more
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: remote, versus server
Date: 12 May 2006
Author: Luigi Auriemma
e-mail: aluigi@xxxxxxxxxxxxx
web: aluigi.org


#######################################################################


1) Introduction
2) Bugs
3) The Code
4) Fix


#######################################################################

===============
1) Introduction
===============


Outgun is an open source 2D capture-the-flag game with multiplayer
support for LAN and Internet through a centralized master server.


#######################################################################

=======
2) Bugs
=======

--------------------------------------------
A] data_file_request command buffer-overflow
--------------------------------------------

The game supports the downloading of map files directly from the server
in which the clients want to play.
The request for the downloading of the map is composed by the command
data_file_request and two text strings for the type and name of the
requested file.
The buffers in which the server stores these two strings have a size of
64 and 256 bytes and the function readString doesn't check the length
of the destination buffer during the copying.

From 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
--------------------------

The leetnet functions used in the game for handling the packets
automatically raise an exception (throw) if a data bigger than 512
(DATA_BUF_SIZE) bytes is received.
The effect is the immediate interruption of the game.

From 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
---------------------------------------------

The leetnet functions support a maximum amount of 64 messages in each
incoming packet but no checks are made for avoiding the reading of the
unallocated memory after the packet if an attacker uses wrong message
sizes.

From src/leetnet/rudp.cpp:

virtual char* process_incoming_packet(int *size, bool *special) {
...
NLulong msgid;
NLshort msgsize;
for (i=0; i<nreliable; i++) { // read all reliable msgs
readLong(udp_data, count, msgid); //id
readShort(udp_data, count, msgsize); //size

//if (debug) printf("(%i,%i)", msgid, msgsize);

// station will process the incoming reliable message
process_incoming_message(msgid, (udp_data + count), msgsize);

//advance count since we didn't "readBlock"
count += msgsize;

//p->add_reliable(msgid, (udp_data + count), msgsize); //data
}
...


----------------------------------------------------------------------
D] harmless buffer-overflow on a global variable in changeRegistration
----------------------------------------------------------------------

changeRegistration is the function for handling the changing of the
registration informations of the clients.
This function uses strcpy for copying the client's token in a buffer of
64 bytes located in the global array of the clients informations.
During my tests (limited by the problem described in bug B) was not
possible to exploit this bug for crashing the server but I was only
able to modify some of the informations of the other players in the
server.

From 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
======


Some of the bugs will be fixed in the next "bot" release.


#######################################################################


---
Luigi Auriemma
http://aluigi.org
http://mirror.aluigi.org