pansou icon indicating copy to clipboard operation
pansou copied to clipboard

Unauthenticated proxy_url parameter lets any caller make the server dial arbitrary internal hosts (SSRF)

Open carfeii opened this issue 1 month ago • 0 comments

Affected versions: confirmed on commit 221665fb2c9279f22af4684ea2d8c0c331eac1cc (2026-10-12).

Summary

The /api/check/links endpoint (unauthenticated by default: authentication is opt-in via the AUTH_ENABLED environment variable and is off unless explicitly configured) accepts a proxy_url field in its JSON body and uses it, unvalidated, as the HTTP/HTTPS/SOCKS5 proxy for the server's own outbound requests to cloud-drive share-check APIs. There is no allowlist on scheme, host, or port, so any caller can force the server to open a TCP connection to an arbitrary address, including loopback, link-local, and other internal-network addresses the server would not otherwise reach on an external caller's behalf.

Details

api/check_handler.go, CheckHandler:

proxyURL := strings.TrimSpace(req.ProxyURL)
if proxyURL == "" {
    proxyURL = strings.TrimSpace(req.Proxy)
}

response, err := getCheckService().CheckWithProxy(req.Items, proxyURL)

service/check_service.go, CheckWithProxy passes that value straight to util.NewHTTPClient(proxyURL), which builds an http.Transport whose Proxy func is BuildProxyFunc(rawProxyURL, ...) in util/http_util.go. normalizeProxyURL in that same file only checks that the value parses with a non-empty scheme (one of http/https/socks5/socks5h) and host:

func normalizeProxyURL(raw string) (string, error) {
	proxyURL, err := url.Parse(raw)
	if err != nil {
		return "", fmt.Errorf("...")
	}
	if proxyURL.Scheme == "" || proxyURL.Host == "" {
		return "", fmt.Errorf("...")
	}
	switch strings.ToLower(proxyURL.Scheme) {
	case "socks5", "socks5h":
		clone := *proxyURL
		clone.Scheme = "socks5"
		return clone.String(), nil
	case "http", "https":
		return proxyURL.String(), nil
	default:
		...
	}
}

Nothing restricts the host to a resolvable public address, or blocks loopback/private/link-local ranges. The resulting value is handed to http.Transport.Proxy, so every outbound request the CheckService makes for that call (to the hardcoded cloud-drive endpoints such as api.aliyundrive.com, api.quark.cn, etc. inside checkAliyun, checkQuark, and the other check* methods) is instead tunneled through whatever host:port the caller named.

config/config.go:

func getAuthEnabled() bool {
	enabled := os.Getenv("AUTH_ENABLED")
	return enabled == "true" || enabled == "1"
}

Authentication is off unless an operator explicitly sets AUTH_ENABLED, and the project's own quick-start Docker instructions do not set it, so the endpoint is reachable by anyone who can reach the service's HTTP port. api/limits.go caps a single request to 256 items (maxCheckItems), so one unauthenticated request can drive up to 256 outbound connection attempts through the caller-chosen proxy target.

Steps To Reproduce

(available upon request)

Impact

An unauthenticated caller can force the pansou server to open TCP connections, up to 256 per request, to any host:port they choose, by supplying it as proxy_url on /api/check/links. In a typical deployment (a single Docker container with the API port exposed, matching the project's own "one-click start" instructions), this lets a remote attacker use the server as a blind network-reconnaissance probe against addresses the attacker could not otherwise reach: loopback services on the host, other containers or services on the same internal/private network, and cloud-provider link-local endpoints (e.g. an instance-metadata service) if the deployment runs in a cloud VM. Each probed item also holds a connection open for up to the 60-second client timeout, so a batch of 256 items against slow or non-responding targets ties up server-side goroutines and connections, a secondary availability concern (CWE-400) on top of the core SSRF.

CVSS 3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L (approximately 6.5, Medium)

CWE-918 (Server-Side Request Forgery), secondary CWE-400 (Uncontrolled Resource Consumption)

carfeii avatar Oct 16 '26 15:10 carfeii