VOGONS


First post, by jspenguin0

User metadata
Rank Newbie
Rank
Newbie

This is a sample exploit showing a flaw in Dosbox's program system. In order for Dosbox to have built-in programs like COMMAND.COM, MEM.COM, etc., it sets up a handler with the callback system (usually #4), and then creates a virtual file on the system containing the callback instruction (FE 38). When the program callback handler is called, it loads a pointer from the program in memory at CS:0x113. Then it calls this pointer to obtain a PROGRAM class object, which it then runs.

However, if a malicious program knew the host location of a portion of emulated memory, it could write its own code to the location, and then call the program callback with the known location, causing the emulator to run the supplied code as a native program.

The most stable section of memory is video ram, the address of which can be obtained by running a debugger and finding the address of the variable vgapages.

This exploit should not be considered serious, for the following reasons:

1. Dosbox is open-source. Simply recompiling it with a different set of options should change the address of video memory.

2. The attack would have to be specific to a single version of Dosbox.

3. Dosbox is cross-platform. An attack would have to be specific to one platform.

Attached is a sample exploit for Dosbox 0.62 on Linux.

Attachments

  • Filename
    dosbox-exploit.tar.gz
    File size
    2.17 KiB
    Downloads
    172 downloads
    File license
    Fair use/fair dealing exception

Reply 1 of 4, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Yeps you are right. Although an exploit is very unlikely i've coded a small fix.

Feel free to test it.

Instead of the pointer it stores the index of vector. that index is used to retrieve the internal pointer.

I'll attach my file.

Attachments

  • Filename
    programs.cpp
    File size
    6.79 KiB
    Downloads
    135 downloads
    File comment
    an updated programs.cpp
    File license
    Fair use/fair dealing exception

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 4, by mirekluza

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Nice. DOSBOX is becoming really popular 😀 when people are starting to look for security holes...
Well, seeing the number of security problems with other software, it would surprise me if there were not any in DOSBOX ...
However I think that the risk is small, since this is a specialized program for limited community... If I was a hacker, I would not probably bother with this kind of program ...
I can imagine sensible abuse only against some defined target (making a speciall attack on a person about whom I would knew he is using DOSBOX).

Nevertheless it is good to fix security problems, so do not be put off by what I wrote above.

Mirek

Reply 3 of 4, by canadacow

User metadata
Rank Member
Rank
Member

However, if a malicious program knew the host location of a portion of emulated memory, it could write its own code to the location, and then call the program callback with the known location, causing the emulator to run the supplied code as a native program.

This isn't an exploit at all, since an application that can access DosBox's emulated memory already has control of the system.

Reply 4 of 4, by jspenguin0

User metadata
Rank Newbie
Rank
Newbie

I wasn't actually looking for security holes -- this one just stood out.

Actually, programs that run under Dosbox are not supposed to have any more control over your system than your typical web page ([In]activeX controls excluded). Any dos virus could only affect the files that Dosbox has access to, and since Dosbox does not emulate actual hard drives, dos viruses cannot infect the MBR, or format your drive. The only vulnerability with the file system I can think of is that a Dosbox-specific virus could run the mount command to give it access to whatever files can be accessed by the user running Dosbox.

Maybe there are some more obscure holes that would take some real searching, but since most of the games Dosbox runs were written well before Dosbox was even thought of, I don't think there will be many dos programs that will exploit any holes (at least not on purpose).