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

Issue with cookies and redirects #1332

Open
Xerbo opened this issue Dec 6, 2024 · 0 comments
Open

Issue with cookies and redirects #1332

Xerbo opened this issue Dec 6, 2024 · 0 comments

Comments

@Xerbo
Copy link

Xerbo commented Dec 6, 2024

Host operating system: output of uname -a

Linux xxx 6.11.3-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024 x86_64 GNU/Linux

blackbox_exporter version: output of blackbox_exporter --version

Tested with master, 0.25.0 and 0.24.0

What is the blackbox.yml module config.

modules:
  alfresco_login:
    prober: http
    timeout: 10s
    http:
      method: POST
      body: "username=xxx&password=xxx"
      headers:
        Content-Type: application/x-www-form-urlencoded
      fail_if_body_not_matches_regexp:
        - 'Alfresco.constants.USERNAME = "xxx"'
      preferred_ip_protocol: "ip4"

What is the prometheus.yml scrape config.

N/A

What logging output did you get from adding &debug=true to the probe URL?

ts=2024-12-06T11:30:50.726812649Z caller=main.go:190 module=alfresco_login target=https://url/share/page/dologin level=info msg="Beginning probe" probe=http timeout_seconds=10
ts=2024-12-06T11:30:50.726904739Z caller=http.go:328 module=alfresco_login target=https://url/share/page/dologin level=info msg="Resolving target address" target=url ip_protocol=ip4
ts=2024-12-06T11:30:50.761472513Z caller=http.go:328 module=alfresco_login target=https://url/share/page/dologin level=info msg="Resolved target address" target=url ip=ip
ts=2024-12-06T11:30:50.761565163Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Making HTTP request" url=https://ip/share/page/dologin host=url
ts=2024-12-06T11:30:50.811980679Z caller=client.go:505 module=alfresco_login target=https://url/share/page/dologin level=info msg="Received redirect" location=https://url/share
ts=2024-12-06T11:30:50.812018849Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Making HTTP request" url=https://url/share host=
ts=2024-12-06T11:30:50.812025779Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Address does not match first address, not sending TLS ServerName" first=ip address=url
ts=2024-12-06T11:30:50.857525478Z caller=client.go:505 module=alfresco_login target=https://url/share/page/dologin level=info msg="Received redirect" location=https://url/share/
ts=2024-12-06T11:30:50.857554498Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Making HTTP request" url=https://url/share/ host=
ts=2024-12-06T11:30:50.857564648Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Address does not match first address, not sending TLS ServerName" first=ip address=url
ts=2024-12-06T11:30:50.889258093Z caller=client.go:505 module=alfresco_login target=https://url/share/page/dologin level=info msg="Received redirect" location=https://url/share/page/
ts=2024-12-06T11:30:50.889296304Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Making HTTP request" url=https://url/share/page/ host=
ts=2024-12-06T11:30:50.889303374Z caller=client.go:259 module=alfresco_login target=https://url/share/page/dologin level=info msg="Address does not match first address, not sending TLS ServerName" first=ip address=url
ts=2024-12-06T11:30:51.175720822Z caller=handler.go:119 module=alfresco_login target=https://url/share/page/dologin level=info msg="Received HTTP response" status_code=200
ts=2024-12-06T11:30:51.183517707Z caller=http.go:538 module=alfresco_login target=https://url/share/page/dologin level=error msg="Body did not match regular expression" regexp="Alfresco.constants.USERNAME = \"xxx\""
ts=2024-12-06T11:30:51.183553377Z caller=handler.go:119 module=alfresco_login target=https://url/share/page/dologin level=info msg="Response timings for roundtrip" roundtrip=0 start=2024-12-06T11:30:50.761641794Z dnsDone=2024-12-06T11:30:50.761641794Z connectDone=2024-12-06T11:30:50.766183658Z gotConn=2024-12-06T11:30:50.795895554Z responseStart=2024-12-06T11:30:50.811885588Z tlsStart=2024-12-06T11:30:50.766195598Z tlsDone=2024-12-06T11:30:50.795828913Z end=0001-01-01T00:00:00Z
ts=2024-12-06T11:30:51.183577828Z caller=handler.go:119 module=alfresco_login target=https://url/share/page/dologin level=info msg="Response timings for roundtrip" roundtrip=1 start=2024-12-06T11:30:50.81206823Z dnsDone=2024-12-06T11:30:50.812956078Z connectDone=2024-12-06T11:30:50.818057807Z gotConn=2024-12-06T11:30:50.839994839Z responseStart=2024-12-06T11:30:50.857446997Z tlsStart=2024-12-06T11:30:50.818074127Z tlsDone=2024-12-06T11:30:50.839926768Z end=0001-01-01T00:00:00Z
ts=2024-12-06T11:30:51.183585628Z caller=handler.go:119 module=alfresco_login target=https://url/share/page/dologin level=info msg="Response timings for roundtrip" roundtrip=2 start=2024-12-06T11:30:50.857618999Z dnsDone=2024-12-06T11:30:50.858515227Z connectDone=2024-12-06T11:30:50.863679927Z gotConn=2024-12-06T11:30:50.87652042Z responseStart=2024-12-06T11:30:50.889166682Z tlsStart=2024-12-06T11:30:50.863698987Z tlsDone=2024-12-06T11:30:50.87647076Z end=0001-01-01T00:00:00Z
ts=2024-12-06T11:30:51.183592268Z caller=handler.go:119 module=alfresco_login target=https://url/share/page/dologin level=info msg="Response timings for roundtrip" roundtrip=3 start=2024-12-06T11:30:50.889355444Z dnsDone=2024-12-06T11:30:50.890137072Z connectDone=2024-12-06T11:30:50.894888858Z gotConn=2024-12-06T11:30:51.118020776Z responseStart=2024-12-06T11:30:51.175681882Z tlsStart=2024-12-06T11:30:50.894901988Z tlsDone=2024-12-06T11:30:51.117976646Z end=2024-12-06T11:30:51.183547667Z
ts=2024-12-06T11:30:51.183642218Z caller=main.go:190 module=alfresco_login target=https://url/share/page/dologin level=error msg="Probe failed" duration_seconds=0.456800419

What did you do that produced an error?

Request a URL that sets cookies and then redirects.

What did you expect to see?

Cookies set on the first request are valid after a redirect.

What did you see instead?

Cookies set on the first request are only set on the resolved IP of the URL; any further redirects lack these cookies as they use the actual URL.

Bypassing the following block of code fixes the issue:

if ip != nil {
	// Replace the host field in the URL with the IP we resolved.
	if targetPort == "" {
		if strings.Contains(ip.String(), ":") {
			targetURL.Host = "[" + ip.String() + "]"
		} else {
			targetURL.Host = ip.String()
		}
	} else {
		targetURL.Host = net.JoinHostPort(ip.String(), targetPort)
	}
}
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

No branches or pull requests

1 participant