Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:12660
HistoryMay 13, 2006 - 12:00 a.m.

[Full-disclosure] Buffer-overflow and NULL pointer crash in Genecys 0.2

2006-05-1300:00:00
vulners.com
10

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

                         Luigi Auriemma

Application: Genecys
http://www.genecys.org
Versions: <= 0.2 and current CVS
Platforms: *nix and *BSD
Bugs: A] tell_player_surr_changes buffer-overflow
B] parse_command NULL pointer crash
Exploitation: remote, versus server
Date: 12 May 2006
Author: Luigi Auriemma
e-mail: [email protected]
web: aluigi.org

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

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

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

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

Genecys is an open source MMORPG project.

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

=======
2) Bugs


A] tell_player_surr_changes buffer-overflow

The function tell_player_surr_changes is affected by a buffer-overflow
which could allow an attacker to execute malicious code.
The problem is caused by the usage of sprintf and strcat on buffers of
256 bytes.

>From server/player.c:

int tell_player_surr_changes(event_t *event)
{
pl_known_t *known, *knext;
object_t *obj;
char buf[256], buf2[256],b2[40];

obj = event-&gt;initiator;

for &#40;known=TAILQ_FIRST&#40;&amp;obj-&gt;pl-&gt;known&#41;; known != NULL; known = knext&#41; {
    knext = TAILQ_NEXT&#40;known, next&#41;;
    if &#40;!event-&gt;action&#41;
        known-&gt;lu--;
    if &#40;known-&gt;bits &gt; 0&#41; {
        sprintf&#40;buf, &quot;chob id:&#37;s&quot;, uid_sprint&#40;b2, &amp;known-&gt;uid&#41;&#41;;
        if &#40;known-&gt;bits &amp; PLKN_NROF&#41; {
            sprintf&#40;buf2, &quot; nrof:&#37;d&quot;, known-&gt;nrof&#41;;
            strcat&#40;buf, buf2&#41;;
        }
        if &#40;known-&gt;bits &amp; PLKN_STATE&#41; {
            sprintf&#40;buf2, &quot; st:&#37;d&quot;, known-&gt;state&#41;;
            strcat&#40;buf, buf2&#41;;
        }
        if &#40;known-&gt;bits &amp; PLKN_NAME&#41; {
            sprintf&#40;buf2, &quot; nm:&#92;&quot;&#37;s&#92;&quot;&quot;, known-&gt;name&#41;;
            strcat&#40;buf, buf2&#41;;
        }
        if &#40;known-&gt;bits &amp; PLKN_NAMEPL&#41; {
            sprintf&#40;buf2, &quot; nmp:&#92;&quot;&#37;s&#92;&quot;&quot;, known-&gt;name_pl&#41;;
            strcat&#40;buf, buf2&#41;;
        }
        if &#40;known-&gt;bits &amp; PLKN_MODEL&#41; {
            sprintf&#40;buf2, &quot; mdl:&#92;&quot;&#37;s&#92;&quot;&quot;, known-&gt;model&#41;;
            strcat&#40;buf, buf2&#41;;
        }
    ...

Note: has not been possible to test this bug in practice due to some
problems while running my test server.


B] parse_command NULL pointer crash

The function which parses the commands sent by the client doesn't check
the return value of a strchr call used for parsing the commands and
their values (CMD:VAL).
If the attacker doesn't use the ':' char the server will crash due to
the access to a NULL pointer.

>From common/netparser.c:

pargs_t *parse_command(char **words, int *command, int count)
{
argtable_t *asp, dummy;
char *cp, *tmp, *p;
size_t span;
…
args = safer_malloc(sizeof(pargs_t)*numargs);
cur = 0;
for (i=1; i < count && words[i] != NULL && *words[i]; i++) {
span = strcspn(words[i], ":");
tmp = strchr(words[i], ':');
tmp++;
…

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

===========
3) The Code

http://aluigi.org/poc/genecysbof.zip

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

======
4) Fix

No fix.
No reply from the developers… the game seems no longer supported.

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


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


Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/