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

Use bodyTextLen instead of readLen for FailHTTPToHTTPS logic #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Nirusu
Copy link
Contributor

@Nirusu Nirusu commented Mar 23, 2022

Replace readLen condition with bodyTextLen for the FailHTTPToHTTPS logic.

How to Test

Setup a Docker Server with TLS, run zgrab against it with FailHTTPToHTTPS & RetryHTTPS enabled. In my case, zgrab will still return "success" with HTTP 400 and "Client sent an HTTP request to an HTTPS server.\n" as the body with the current master. With this fix, zgrab will actually retry HTTPS and get the requested content from the Docker API.

Notes & Caveats

This fixes a bug where the FailHTTPToHTTPS logic would not trigger when the Go's HTTP library cannot determine the correct ContentLength (resp.ContentLength is -1), which causes readLen to be maxReadLen, which is 262144 by default.

This is way above the 1024 bytes hard limit in the if condition which contains the FailHTTPToHTTPS logic, thus it is never entered even if the body is actually short with one of the expected message and falls inside this limit.

Issue Tracking

Have not created an issue for this, as the fix is easy.

respContentLength can be -1 in certain cases, in which case
readLen will be maxReadLen for the current scan. This will,
however, then cause the FailHTTPToHTTPS if-condition to
fail as the readLen is > 1024, even though the body content
length can be in this range. So let us use the actual body
length for the check to avoid this issue.
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.

1 participant