Skip to content

Multiple bugs in the driver's implementationΒ #12

@repnz

Description

@repnz

I know it's a POC, but I thought it would be good to fix this anyway -

  1. There is a stack buffer overflow reading the 'pid' from user mode. Replace inBufferLength with sizeof(pid).

    strcpy_s(pid, inBufferLength, inBuf);

  2. The output buffer's length is not checked

    RtlCopyBytes(buffer, data, outBufferLength);

  3. This memory is not freed anywhere

    LPSTR result = ExAllocatePool(NonPagedPool, sizeof(ULONG) + 20);;

  4. This buffer was allocated with length=(sizeof(ULONG) + 20), why is the param to sprintf_s longer?

    sprintf_s(result, 2 * sizeof(ULONG) + 30, "Found offsets: %lu & %lu", PID_OFFSET, LIST_OFFSET);

  5. This string is not used anywhere (copied from the microsoft ioctl sample:) )

    PCHAR data = "This String is from Device Driver !!!";

  6. Here, you use 'datalen' which is the length of the string from the sample instead of the real result string:

    Irp->IoStatus.Information = (outBufferLength<datalen ? outBufferLength : datalen);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions