Skip to content

bug: null pointer dereference in Windows hotplug callback (lparam not validated before from_address) #113

@RockyOmvi

Description

@RockyOmvi

Describe the bug

In src/packages/buskill/__init__.py, the hotplugCallbackWin function (Windows USB hotplug handler) calls DEV_BROADCAST_HDR.from_address(lparam) without first validating that lparam is a valid pointer. Some WM_DEVICECHANGE subtypes (e.g., DBT_CONFIGCHANGED) pass NULL for lparam, which would cause from_address(0) to access invalid memory and crash the process.

Code reference

src/packages/buskill/__init__.py:175:

dev_broadcast_hdr = DEV_BROADCAST_HDR.from_address(lparam)

The wparam check at line 169 only validates that the event is DBT_DEVICEREMOVECOMPLETE, but does not ensure lparam is non-null before dereferencing.

Expected behavior

Add a null check on lparam before calling from_address:

if lparam == 0:
    return True
dev_broadcast_hdr = DEV_BROADCAST_HDR.from_address(lparam)

Steps to reproduce

  1. Run BusKill on Windows
  2. Trigger a system-level WM_DEVICECHANGE event that is not device-specific (e.g., changing power source, docking station events)
  3. Process crashes

Severity

High — null pointer dereference causing crash on Windows systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions