Skip to content

fix(hidpp10): validate Receiver register and event parsers#552

Open
jelmerdehen wants to merge 1 commit into
PixlOne:mainfrom
jelmerdehen:fix/hidpp10-receiver-validation
Open

fix(hidpp10): validate Receiver register and event parsers#552
jelmerdehen wants to merge 1 commit into
PixlOne:mainfrom
jelmerdehen:fix/hidpp10-receiver-validation

Conversation

@jelmerdehen
Copy link
Copy Markdown

Summary

Several Receiver methods index device-supplied response buffers and HID++ reports without checking the buffer length:

  • getNotificationFlags, getConnectionState, getDeviceActivity, getPairingInfo, and getExtendedPairingInfo dereference bytes from a register response that the device controls.
  • deviceConnectionEvent, fillDeviceDiscoveryEvent, pairStatusEvent, boltPairStatusEvent, discoveryStatusEvent, and passkeyEvent only assert on subId / type and then index paramBegin()[N]. Asserts compile out under NDEBUG, so a malicious or buggy device can feed a Short report to a Long-expecting parser and trigger out-of-bounds reads up to ~14 bytes past the heap allocation.

logid runs as root, so reads here are at minimum an information leak from a process the device should not be able to read.

Fix

  • Replace assert with runtime checks that throw std::runtime_error on bad subId / type.
  • Validate response and paramEnd - paramBegin length before indexing.

Throwing was chosen over silent return so the calling state machine sees the error and can drop the malformed report instead of acting on uninitialized fields.

Test plan

  • Builds cleanly.
  • Pair / unpair flows on Bolt and Unifying receivers still work.
  • Stub a Short response to a Long-expecting parser and confirm we throw rather than read OOB.

Several Receiver methods indexed device-supplied response buffers and
HID++ reports without checking the buffer length:

  * getNotificationFlags, getConnectionState, getDeviceActivity,
    getPairingInfo and getExtendedPairingInfo dereferenced bytes from
    a register response that the device controls.
  * deviceConnectionEvent, fillDeviceDiscoveryEvent, pairStatusEvent,
    boltPairStatusEvent, discoveryStatusEvent and passkeyEvent only
    asserted on subId/type, so a malicious or buggy device could feed
    a Short report to a Long-expecting parser and trigger out-of-bounds
    reads. Asserts compile out under NDEBUG.

Replace asserts with runtime checks that throw on bad subId or short
type, and validate response/param length before indexing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant