Shared HTTP transport follows cross-origin and downgrade redirects #3316
Closed
rustytrees
started this conversation in
Potential issues
Replies: 3 comments
|
AI is lousy. |
0 replies
|
AI is lousy. |
0 replies
|
Robot-to-robot message: This report is mostly nonsense in this context. dnscrypt-proxy is a local DNS resolver. It contacts administrator-configured Redirect handling exists. That fact does not create a meaningful SSRF vulnerability in normal deployments. An attacker needs control The resolver-list path also verifies Minisign signatures. Redirects cannot inject an accepted resolver list. Rejecting redirects is optional defense in depth. It is not an urgent security issue. Robots are not taking over the universe yet. Please calibrate the threat model before raising alarms. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What is happening?
The shared
XTransport.Fetch()HTTP client uses Go’s default redirect behavior. It sets a transport and timeout, but noCheckRedirectpolicy:Go therefore follows redirects automatically (up to its default limit), including cross-origin redirects and HTTPS-to-HTTP redirects.
Fetch()callsclient.Do()for the original request and again for the HTTP/2 fallback, so the redirect is followed before dnscrypt-proxy evaluates the returned status code:client.Do(), lines 780-792client.Do(), lines 810-817Why cross-origin redirects matter here
The custom
DialContextextracts the host from the address supplied for each connection. If a redirect selects a host with no cached IP, it falls back to dialing that hostname normally:As a result, an HTTP endpoint trusted for one configured URL can redirect dnscrypt-proxy to a different origin selected by that endpoint, including an address reachable only from the proxy host. This creates an outbound-request/SSRF primitive. An HTTPS endpoint can also redirect to HTTP, crossing the scheme boundary without an explicit policy decision.
Affected paths
All
Get()/Post()helpers route through the sameFetch()method:GetWithCompression,Get, andPost, lines 905-928GetWithCompression, lines 159-160Source-list signatures still protect the integrity of accepted resolver-list contents; following a redirect does not bypass
checkSignature(). The remaining concerns are the unintended outbound connection, scheme/origin trust transition, and behavior of encrypted-DNS requests that are transparently redirected.Exposure and impact
Exploitation requires control of, or the ability to induce a redirect from, an endpoint dnscrypt-proxy is configured to contact. HTTPS prevents an ordinary network attacker from injecting a redirect unless TLS trust is also compromised; plain-HTTP configured sources do not have that transport protection.
Depending on the configured endpoint and redirect status, possible effects include:
POST behavior varies by redirect status under Go’s redirect rules; the attached tests specifically cover a
303POST redirect in addition to all standard redirect statuses for GET.Reproduction and tested patch
A patch and regression tests are available in PR #3313. The PR is currently closed, but its commit is still available for review. It adds
CheckRedirectreturninghttp.ErrUseLastResponse, causing the existing non-2xx handling to reject the redirect response instead of contacting its target.The tests cover:
direct requests continuing to work;
301,302,303,307, and308;cross-origin redirects;
HTTPS-to-HTTP downgrade;
a POST redirect;
verification that the redirect target is never contacted.
Patch commit
Redirect regression tests, lines 12-160
Validation run for that commit:
All completed successfully.
Expected behavior / alternatives
The safest policy is to reject redirects for these protocol and source-fetching requests and require final URLs in configuration. If redirect compatibility is required,
CheckRedirectcould instead enforce an explicit policy such as same-origin HTTPS redirects only, reject scheme downgrades, and place a small hop limit. Cross-origin or downgrade behavior should not occur implicitly.All reactions