Add support for TCP Fast Open to prevent false negatives#1204
Closed
cnotin wants to merge 1 commit intonmap:masterfrom
cnotin:patch-1
Closed
Add support for TCP Fast Open to prevent false negatives#1204cnotin wants to merge 1 commit intonmap:masterfrom cnotin:patch-1
cnotin wants to merge 1 commit intonmap:masterfrom
cnotin:patch-1
Conversation
|
Thanks for this patch! I thought about this a while and decided that it's best that we do proper TLV checking for all TCP options except EOL and NOP (which are single-byte options). Doing it this way, there's no special case for Fast Open. The purpose of this function is to validate that known-length options have those lengths, and Fast Open is a variable-length option, so it can't really be checked in the same way. I just pushed an alternate change that does this, and I'll credit you with discovering the problem in the CHANGELOG. |
nmap-bot
pushed a commit
that referenced
this pull request
May 1, 2018
…ailing validation. See #1204
nmap-bot
pushed a commit
that referenced
this pull request
May 1, 2018
Author
|
Thanks @dmiller-nmap for your quick feedback and for crediting me! |
Closed
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.
Nmap currently discards SYN-ACK packets having the TCP Fast Open option (RFC 7413) set. Thus leading to false negative results.
This patch implements the support of this option, fixing the false negative.
I tested successfully this patch in the field, of course.
Full story:
During an internal pentest, I discovered a false negative on a TCP port that I knew for sure was open. SYN scans did not see it, whereas connect scans were good.
Running nmap with
-dddI saw that the SYN ACK packet was discarded:Rejecting TCP packet because of bad TCP headerIn Wireshark, I saw that the TCP Fast Open option was enabled.
Its kind is "34" which is not currently handled in the code. Therefore the code reads the next byte, which is the length of the option and incorrectly interprets it as a kind. According to the RFC, the length is a range from 6 to 18. In my case it was 8, so the code assumed it was a timestamp header and it was then incorrect.
I know that TCP Fast Open option should not appear in SYN-ACKs if the option was not present in the prior SYN. However, this is what I observed on my client's network...
This is also related to this message in the mailing list.
You can test it against the following scapy code, after preventing the default behavior of the kernel with
iptables -A OUTPUT -p tcp --tcp-flags RST RST --sport 8000 -j DROPWith the current nmap, you get:
And with the patch: