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

dns: parser reads into garbage on misreported packet size #468

Merged
merged 1 commit into from
Feb 26, 2022

Conversation

bwillcox
Copy link
Contributor

@bwillcox bwillcox commented Feb 24, 2022

The unit test demonstrates the following issue. The DNS packet is valid, but the packet size is misreported to be larger than the size of the valid packet. Attempting to get RR's for the additional section causes the parser to read into garbage past the end of the packet. This results in a malformed packet exception.

There is no language in the spec that addresses this use case. However, the RR counts in the header provide sufficient data for the parser to know when it could stop parsing.

Added code to limit RR fetch to count specified in header.

@bwillcox bwillcox changed the title dns: parser reads into garbage on misreported packet size dns: parser reads into garbage on misreported packet size (WIP) Feb 24, 2022
@bwillcox bwillcox changed the title dns: parser reads into garbage on misreported packet size (WIP) dns: parser reads into garbage on misreported packet size Feb 26, 2022
@mfontanini
Copy link
Owner

Nice one. I'm curious whether you found this in the wild and how it would actually come to be? e.g. what would the trailer padding be in a real packet. Regardless, this seems reasonable so merging!

@mfontanini mfontanini merged commit 7204fbd into mfontanini:master Feb 26, 2022
@bwillcox
Copy link
Contributor Author

bwillcox commented Feb 27, 2022

Nice one. I'm curious whether you found this in the wild and how it would actually come to be? e.g. what would the trailer padding be in a real packet. Regardless, this seems reasonable so merging!

It's from the wild. We don't understand the bad packet size root cause. It only happens on some networks and one operating system and is only reproducible in some environments. The bad data seems random - mostly zeroes. This was a major trouble maker! :)

laudrup pushed a commit to laudrup/libtins that referenced this pull request Nov 23, 2022
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.

3 participants