Repository navigation
Conversation
A download or upload URL that answered with an error status, or an upload URL that answered with a redirect, was timed as if it carried data. Such answers are not counted now, and a server that only refuses fails like one that is down.
A server could answer with a redirect to an http:// URL, and the probe, the IP lookup, the transfers and the telemetry request followed it. A run that asked for HTTPS was then measured, or its result sent, over plain HTTP.
An upload does not follow a redirect, so a server whose upload URL redirects, as most public servers do under --insecure, gave no upload result. A server whose probe is redirected is now asked with an empty POST where its upload URL is, and the test runs against that place.
maddie
left a comment
There was a problem hiding this comment.
Review of 2ebeb18
The commit itself is small: defs/server.go (+113), defs/upload_redirect_test.go (new), secure_redirect_test.go (±40). Build, vet, both test runs including -race, and the new redirect tests pass. Discovery and payload forwarding work for the cases the tests cover. Two points block approval.
❌ Security — the upload can leave the server's origin, including under --secure
uploadTarget (defs/server.go:928-995) follows 301/302/307/308 to any scheme, host and port, and defs/server.go:608-613 then sends the real payload there. The only policy applied is the client's redirect policy; under --secure that is refuseDowngrade (speedtest/speedtest.go:495-502), which rejects HTTPS -> HTTP but not a change of host.
Probe on this head: an HTTPS frontend redirecting its upload POST to a second HTTPS server on a different host and port; the second host received 143,015,936 payload bytes and the CLI exited 0. The same probe over plain HTTP delivered 569,376,768 bytes to the second host.
Why this matters: the server list is remote. A hostile or compromised listed server can use the client to POST a large random body to any reachable host and port, including an intranet service. Downloads and telemetry already follow redirects, but this adds an upload POST primitive, and it restores redirect following that #160 deliberately removed.
To resolve, pick one and add a test that pins it:
- restrict upload discovery and the payload to the listed upload URL's origin (scheme + host + port), or
- have the maintainer explicitly accept cross-origin upload POSTs and document it as intended behavior.
I cannot approve the cross-origin version without that decision, because it is a new SSRF primitive, not a refactor.
❌ Inherited from #160 — read-then-hang still reports a result
#164 is one commit whose parent is exactly 168a242, so it carries #160's commits and its open blocker at defs/server.go:869 (a body handed over whole after at least 250 ms and never answered is still counted as a successful upload). Merge order is #160 first, then rebase #164. The decision requested in the #160 turn-4 review also decides this PR.
⚠️ The empty POST proves reachability, not that the target consumes the payload
defs/server.go:989-995 accepts any 2xx answer to the empty POST and selects that URL. A target that answers 200 without reading is selected; the payload POST then also gets 200, and Upload reports a rate for bytes that were never read. Probe: rate=66.198 Mbps total=9109504 err=<nil>, target read 0 bytes. Any server can answer before reading, so this is a limit of the heuristic rather than a new bug, but the code comment should say that the empty POST only proves the URL answers, and a regression test for a 2xx-without-read target would document the behavior.
💡 Nitpicks
defs/upload_redirect_test.go:22-28(uploadSeen.count) never records the request method, soTestUploadFollowsItsURLwould pass if the payload went out as a non-POST with a body. AssertPOSTfor the payload requests.TestUploadAsksNothingOfAServerThatDoesNotRedirect(defs/upload_redirect_test.go:95) andTestUploadDoesNotDependOnTheEmptyPOST(:122) also pass on168a242; onlyTestUploadFollowsItsURL,TestUploadStopsFollowingALoopand the newsecure_redirect_test.gocases guard the feature.defs/server.go:982logsnext.Redacted(), which keeps the query string; a signed redirect URL would appear in--debugoutput. Consider logging host and path only.- A server that redirects only the POST and not the probe is still refused. The PR body says so, and the probe confirms
HTTP 302with no payload at the target; worth a line in the code comment next toprobeRedirected. - The PR description lists changes to
defs/bytes_counter.go,speedtest/helper.goandspeedtest/speedtest.go; those come from #160 and are not in this commit. Trim the description so the diff and the text agree.
Verification
go build ./...,go vet ./...: pass.go test -count=1 ./...: pass (root 25.6s, defs 71.8s).go test -count=1 -race ./...: pass, no race reports (root 43.2s, defs 73.9s).go test -run TestUpload -v ./defsandgo test -run TestSecureRefusesARedirectedUpload -v .: pass.- Probes: same-host redirect delivers the payload; cross-host delivers it (the security finding); a redirect loop stops after 10 requests with
stopped after 10 redirects; 301/302/307/308 all deliver; 200-without-read gives the false success above;--secureHTTPS->HTTP is refused with zero plain-HTTP requests; POST-only redirect stays refused. - On the parent
168a242with two stubs forprobeRedirected/uploadProbeTimeout:TestUploadFollowsItsURLfails for all four statuses,TestUploadStopsFollowingALoopfails, and the new secure cases fail. The two fallback tests pass on the parent. - Not verified: real public/CDN servers, HTTP/3, cookies or Authorization across the redirect chain, 303 behavior, and public TLS validation (the cross-host probe used
--skip-cert-verify).
Stacked on #160 and needs its two commits.
With #160 an upload does not follow a redirect, so a server whose upload URL redirects gives no upload result. With
--insecure, 13 of the 23 servers in the public list redirect the upload to HTTPS, and all 13 redirect the probe as well. Now a server whose probe is redirected is asked with an empty POST where its upload URL is, and the payload goes there. A single redirect costs two empty POSTs, one that gets the redirect and one where it ends. A server that does not redirect its probe sees no new request. If the redirects do not end at a place that takes the POST, the listed URL is used as before.A server that redirects only POST, and not the GET of the probe, is not covered.
One of them, upload only: