fix(hidpp10): bound writes in Bolt getDeviceName#545
Open
jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
Open
fix(hidpp10): bound writes in Bolt getDeviceName#545jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
jelmerdehen wants to merge 1 commit intoPixlOne:mainfrom
Conversation
The Bolt branch of Receiver::getDeviceName trusted the size byte from the device's pairing-info register without validating it against the allocated string. When the device returned a size smaller than chunk_size (1..16), the inner loop wrote up to 16 bytes past the end of the std::string buffer, producing a heap-buffer overflow with attacker-controlled bytes. The daemon runs as root and the response originates from the receiver firmware, so a malicious or compromised Bolt receiver (or RF/USB attacker spoofing register replies) could corrupt the heap of a root process. Add bounds checks on every write and on subsequent register reads. Empty/short responses return an empty name instead of dereferencing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Receiver::getDeviceName(Bolt branch) trusts the size byte from the device's pairing-info register without validating it against the allocated string. When the device returns a size smaller thanchunk_size(1..16), the inner loop writes up to 16 bytes past the end of thestd::stringbuffer, producing a heap-buffer overflow with attacker-controlled bytes.Impact
logid runs as root via systemd. The response originates from receiver firmware, so a malicious or compromised Bolt receiver, or an RF/USB attacker spoofing the
0x83register reply, could corrupt the heap of a root process.Reproducer: any Bolt receiver that returns
size < 17in the first byte of the pairing-info name response.Fix
name.size()andresp.size().Test plan