postgres: raise detection threshold to prevent false positives (#125)#734
Draft
Seanstoppable wants to merge 2 commits into
Draft
postgres: raise detection threshold to prevent false positives (#125)#734Seanstoppable wants to merge 2 commits into
Seanstoppable wants to merge 2 commits into
Conversation
) The postgres scanner could misidentify non-Postgres services as PostgreSQL when they responded with an 'N' byte (or any non-'E' response) to the version probe. This is the scenario described in issue zmap#125. Changes: - Version probes (0.0 and 255.255) now require the server to return a valid 'E'-type error packet. Any other response type causes the scan to bail with SCAN_PROTOCOL_ERROR. - Add isValidPostgresError() to validate that 'E' packets contain the minimum structured fields (severity, code, message) expected from a real PostgreSQL server. - Add tests for false-positive scenarios: bare 'N' byte, invalid error fields, immediate close, and valid server responses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Older Postgres versions (e.g. 9.3-9.5) respond to bogus version probes with a raw \n\0-terminated error string rather than a structured 'E' packet with tagged fields. These have Length=0 in the parsed ServerPacket. Only apply isValidPostgresError validation to structured error packets (Length > 0). Pre-startup errors (Length == 0) are still accepted as valid Postgres detections since the 'E' type byte combined with the \n\0 termination is sufficient evidence. Add TestPreStartupError_OlderPostgres to cover this case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
The postgres scanner could misidentify non-Postgres services as PostgreSQL when they responded with an 'N' byte (or any non-'E' response) to the version probe. This is the scenario described in issue #125.
Changes: