Forum

"save pak0.pak" vulnerability

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

"save pak0.pak" vulnerability

Postby Spirit » Fri Apr 25, 2014 8:06 am

Curiosity overwrites the pak file...

If you do a save game with arbitrary names, the engine should check if it might overwrite existing files (and then prompt) and probably make sure the extension is .sav.

I tested Requiem, Quakespasm, Fitzquake, Darkplaces and FTEQW with this.

Fitzquake and by extension Quakespasm are affected as is Darkplaces. FTEQW fails silently and Requiem saves as pak0.sav.

Quakespasm's output on Linux:
]save pak0.pak
Saving game to /home/me/.quakespasm/id1/pak0.pak...


and on the next start:
QUAKE ERROR: ./id1/pak0.pak is not a packfile


Please always append .sav to savegames if the user-supplied name does not already end in .sav!

edit: I hope it is clear that this affects all commands/cvars where filenames are supplied by the user or server!
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Re: "save pak0.pak" vulnerability

Postby Spirit » Fri Apr 25, 2014 11:18 am

It seems like an original bug, I tried it with the shareware. How on earth did this survive 18 years?

QUAKE.EXE even lets me write relative paths like "save ../config.sys", that sounds familiar though and I know some engines have at least that fixed.

I am sure other filesystem writing commands are affected too.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Re: "save pak0.pak" vulnerability

Postby Spike » Fri Apr 25, 2014 5:46 pm

its not just saved games. try it with demos too. and frik_file etc

also, try:
game . ; gamedir . ; save opengl32.dll
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: "save pak0.pak" vulnerability

Postby leileilol » Sat Apr 26, 2014 1:02 am

save ..\..\..\..\..\..\msdos.sys
save ..\..\..\..\..\..\ntldr
save ..\..\..\..\..\..\boot.ini
echo "HA I FUCED UR SYSTEM BICH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"


Yeah this hole is fucking dangerous

Fortunately Windows 7 has VirtualStore these days...
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: "save pak0.pak" vulnerability

Postby Spike » Sat Apr 26, 2014 1:07 am

add a clear command followed by a map change or something and they won't even realise you did it.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: "save pak0.pak" vulnerability

Postby szo » Sat Apr 26, 2014 7:17 am

Testing a patch to fix this.

leileilol wrote:save ..\..\..\..\..\..\msdos.sys
save ..\..\..\..\..\..\ntldr
save ..\..\..\..\..\..\boot.ini
echo "HA I FUCED UR SYSTEM BICH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"


Yeah this hole is fucking dangerous

Fortunately Windows 7 has VirtualStore these days...


Read the code before posting such a thing.
szo
 
Posts: 132
Joined: Mon Dec 06, 2010 4:42 pm

Re: "save pak0.pak" vulnerability

Postby szo » Sat Apr 26, 2014 7:52 am

Fixed in the quakespasm svn repository as of rev. 902:
http://sourceforge.net/p/quakespasm/code/902/
szo
 
Posts: 132
Joined: Mon Dec 06, 2010 4:42 pm

Re: "save pak0.pak" vulnerability

Postby mh » Sun Apr 27, 2014 12:35 pm

stuffcmd save pak0.pak

Just saying.

Bye again!
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: "save pak0.pak" vulnerability

Postby szo » Sun Apr 27, 2014 1:15 pm

mh wrote:stuffcmd save pak0.pak


Well, no longer an issue with quakespasm which will give you a nice and valid pak0.pak.sav now.
szo
 
Posts: 132
Joined: Mon Dec 06, 2010 4:42 pm

Re: "save pak0.pak" vulnerability

Postby jitspoe » Mon Apr 28, 2014 2:28 pm

mh wrote:stuffcmd save pak0.pak

Just saying.

Bye again!

Can you save in a multiplayer game?
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: "save pak0.pak" vulnerability

Postby Spike » Mon Apr 28, 2014 7:47 pm

stuffcmd(self, "disconnect;maxplayers 1;deathmatch 0;coop 0;map start;save pak0.pak;quit\n");
yes, you can save in a multiplayer game.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: "save pak0.pak" vulnerability

Postby Spirit » Mon Apr 28, 2014 9:07 pm

Or just send "record pak0.pak".

I hope it is clear that this affects all commands/cvars where filenames are supplied by the user!
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Re: "save pak0.pak" vulnerability

Postby qbism » Tue Apr 29, 2014 12:59 am

Could happen in SP with an evile progs.dat.
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Re: "save pak0.pak" vulnerability

Postby jitspoe » Tue Apr 29, 2014 3:30 am

Spike wrote:stuffcmd(self, "disconnect;maxplayers 1;deathmatch 0;coop 0;map start;save pak0.pak;quit\n");
yes, you can save in a multiplayer game.

Touche.

On the plus side, it looks like this was fixed in Quake2, so idtech2+ based engine users shouldn't have to worry.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: "save pak0.pak" vulnerability

Postby r00k » Tue Apr 29, 2014 5:54 am

Looks like Joe fixed this in JoeQuake long ago,
Code: Select all
void COM_ForceExtension (char *path, char *extension)
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest