-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Memory corruption bugs in map parser #615
Comments
Hi This is brilliant, thankyou very much. I'll try and get patches to fix these when I'm set up at home again (combination of really bad time at work and the wall-socket hissing, so can't use normal PC at the moment). Can I ask where you got the test cases from, is there a suite somewhere or did you create them yourself? Thanks again, |
Hi meag, the test cases are the result of fuzzing with AFL++. As an initial corpus I took original maps that are downloaded by the nquake installer script. |
For QW-Group#615 Reported by mmmds
There are probably more to add... Fixes QW-Group#615 Reported by mmmds
For QW-Group#615 Reported by mmmds
The game client does not validate loaded maps. I found 11 places when the game crashes due to memory corruption bugs when loading a malformed map. Malformed maps may be delivered by a server the client connects to or downloaded from 3rd party services. There are at least two places where write buffer overflow occur, so these bugs may have security implications (potentially code execution instead of just crashing). For the buffer overflow crashes I did initial analysis, for the rest I just upload the test cases and brief information when it crashes.
ezQuake version: 3.2.3
OS/device including version: Ubuntu 20.04 x86_64
Steps to reproduce:
move a map to qw/maps
run the game
open console and type
map <mapname>
map 477.bsp.zip
visleafs
value comes from the map file. the calculation for the buffer size (cmodel.c
, line 997) is susceptible to integer overflow. In the result, less memory than necessary is allocated andmemcpy
in the line 1014 copies data outside thescan
buffer.In the case of the map477.bsp:
visleafs
is set to 185352, the calculation results in value 9248:buffer ends at:
We reach first iteration of the loop where 23172 bytes are copied.
before
memcpy
:after
memcpy
:here we see that data was written also outside the buffer. The loop continues and at this specific case the game crashes at
i=52
, wherep
(also user controlled) modifiesin
pointer to point to non-accessible memory.The
COM_Parse
function takes data coming from a map and iterates over it copying it byte by byte into the fixed size (1024) buffercom_token
until a specific symbol is encountered. While iterating over the data, the function does not considercom_token
's size, so it may overflow and write data outside thecom_token
buffer affecting among others thecom_argv
pointer. In this case,com_argv
is overwritten with map data and the game crashes later when this pointer is being accessed.The text was updated successfully, but these errors were encountered: