Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insufficient validation of PUBLISH message #144

Open
snej opened this issue Oct 6, 2021 · 2 comments
Open

Insufficient validation of PUBLISH message #144

snej opened this issue Oct 6, 2021 · 2 comments

Comments

@snej
Copy link

snej commented Oct 6, 2021

There's some missing packet-length validation in the PUBLISH packet handler, mqtt_unpack_publish_response. This makes the library vulnerable to a bad PUBLISH packet with an overly-long topic name. The library could definitely be made to read garbage past the end of a buffer, and possibly crash.

The bug is that the remaining packet length (mqtt_response->fixed_header.remaining_length) is only checked once, to ensure it's 4 bytes long. There is no check that the packet is large enough to hold the topic name and packet ID.

@LiamBindle
Copy link
Owner

@snej Thanks for point this out. Would you be able to submit a PR?

@snej
Copy link
Author

snej commented Oct 8, 2021

Sorry, I'm not actually using the library, I was reading through the code to see how it worked.

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

No branches or pull requests

2 participants