-
Notifications
You must be signed in to change notification settings - Fork 647
Open
Labels
Description
The client crashes when an invalid map (4.map.zip) is loaded. Such a map can be delivered to the client by a malicious server.
Tested on Ubuntu 20.04 x86_64, Teeworlds version: f35da54b6f2c5f9fd4bbd4559f887ccf8f8cc526
Compilation with ASAN:
export CXXFLAGS="-ggdb -O0 -fsanitize=address -fno-omit-frame-pointer"
export CFLAGS="-ggdb -O0 -fsanitize=address -fno-omit-frame-pointer"
cmake ..
make
Run and connect to a server that delivers an invalid map:
./teeworlds "connect 127.0.0.1" "gfx_fullscreen 0" "gfx_screen_height 240" "gfx_screen_width 360"
[...]
=================================================================
==31420==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61f0000e7d34 at pc 0x5555559965c5 bp 0x7ffffffd8c80 sp 0x7ffffffd8c70
READ of size 4 at 0x61f0000e7d34 thread T0
#0 0x5555559965c4 in CMap::Load(char const*, IStorage*) /home/osboxes/teeworlds/teeworlds-asan/src/engine/shared/map.cpp:48
#1 0x5555555f0c6f in CClient::LoadMap(char const*, char const*, SHA256_DIGEST const*, unsigned int) /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:807
#2 0x5555555f8408 in CClient::ProcessServerPacket(CNetChunk*) /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1251
#3 0x5555555f997e in CClient::PumpNetwork() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1596
#4 0x5555555f9d46 in CClient::Update() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1766
#5 0x5555555fc9a0 in CClient::Run() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:2108
#6 0x5555555d24e5 in main /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:2704
#7 0x7ffff68e10b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#8 0x5555555dc48d in _start (/home/osboxes/teeworlds/teeworlds-asan/build/teeworlds+0x8848d)
Address 0x61f0000e7d34 is a wild pointer.
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/osboxes/teeworlds/teeworlds-asan/src/engine/shared/map.cpp:48 in CMap::Load(char const*, IStorage*)
Shadow bytes around the buggy address:
0x0c3e80014f50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3e80014f60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3e80014f70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3e80014f80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3e80014f90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c3e80014fa0: fa fa fa fa fa fa[fa]fa fa fa fa fa fa fa fa fa
0x0c3e80014fb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3e80014fc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c3e80014fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c3e80014fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c3e80014ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==31420==ABORTING
Compilation without ASAN:
export CXXFLAGS="-ggdb -O0"
export CFLAGS="-ggdb -O0"
cmake ..
make
Run and connect to a server that delivers an invalid map:
./teeworlds "connect 127.0.0.1" "gfx_fullscreen 0" "gfx_screen_height 240" "gfx_screen_width 360"
[...]
Segmentation fault (core dumped)