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

Fix out of bounds reads in packet parsing #2954

Closed
wants to merge 3 commits into from
Closed

Conversation

domenpk
Copy link

@domenpk domenpk commented Oct 24, 2024

Should be straightforward. I do not think these have any security impact, but reading out of bounds isn't nice.

This was found with AFL and the test code included in last commit.

Btw, while doing this, I have also come across another out of bounds read in DNS code, which is already described in https://tomerfry.github.io/2023/05/26/Fuzzing-NMAP-With-AFL++.html
From my experiments it's an over-read in input buffer to DNS::Packet::parseFromBuffer(). I haven't analysed it enough to figure out the root cause, hence no patch.

Consuming bytes reduces the number of bytes left.
Fix this for PAD1 case where it was increased instead.
PacketParser::parse_packet code does not account for an edge case
where a RAW packet is added at the end of this_packet[], causing
an out of bounds read in the array processing code that follows.
@nmap-bot nmap-bot closed this in 068dd4b Feb 27, 2025
@dmiller-nmap
Copy link

Thanks for these fixes! The PacketParser::parse_packet change, adding an extra element on the array, just covered the problem without addressing the logical bug that was the cause, so I made some modifications there. The fix (and your changelog credit) will post shortly.

The DNS::Packet::parseFromBuffer() issue was most likely fixed in e633a21, since it appears the code you fuzzed was Nmap 7.94 (May 2023). That commit changed the way DNS label compression was parsed to ensure there were no recursions.

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