-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The endpoint took any URL and fetched it\n\nEch0 is an open-source self-hosted publishing platform for personal idea sharing. The maintainer is `lin-snow`. The typical operator runs Ech0 on a VPS or homelab and exposes it to the public internet so they can publish their notes from any device. In versions 4.2.1 through 4.2.7, one of the routes that VPS exposes is registered like this:\n\n```go\n// internal/router/common.go (v4.2.1)\nappRouterGroup.PublicRouterGroup.GET(\"/website/title\", h.CommonHandler.GetWebsiteTitle())\n```\n\n`PublicRouterGroup` means no session cookie, no API key, no authentication of any kind. The handler binds a single `website_url` query parameter, hands it to the service, and returns whatever `` tag the server finds in the response body:\n\n```go\n// internal/handler/common/common.go\nfunc (commonHandler *CommonHandler) GetWebsiteTitle() gin.HandlerFunc {\n return res.Execute(func(ctx *gin.Context) res.Response {\n var dto commonModel.GetWebsiteTitleDto\n if err := ctx.ShouldBindQuery(&dto); err != nil {\n return res.Response{Msg: commonModel.INVALID_QUERY_PARAMS, Err: err}\n }\n title, err := commonHandler.commonService.GetWebsiteTitle(dto.WebSiteURL)\n ...\n })\n}\n```\n\nThe PoC by `fineman999` reduces the exploit primitive to three lines:\n\n```sh\ncurl -G \\\n --data-urlencode \"website_url=http://169.254.169.254/\" \\\n \"http://target:6277/api/website/title\"\n```\n\nAnything the Ech0 server can reach by IP or hostname is in scope. The `<title>` extraction is the exfiltration primitive: small, but enough to confirm which internal services are reachable, and enough to read the title element of any internal HTML response that has one. On vulnerable Ech0, the lab's controlled HTML returns the exfiltrated title verbatim:\n\n```http\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=utf-8\n\n{\"code\":1,\"msg\":\"获取网站标题成功\",\"data\":\"ECH0-SSRF-CVE-2026-35037\"}\n```\n\n`获取网站标题成功` translates to \"successfully obtained website title.\" Ech0 has done what the attacker asked.\n\n## The function the handler reached for\n\nThe service in v4.2.1 hands the URL directly to `httpUtil.SendRequest`:\n\n```go\n// internal/service/common/common.go (v4.2.1)\nfunc (s *CommonService) GetWebsiteTitle(websiteURL string) (string, error) {\n websiteURL = httpUtil.TrimURL(websiteURL)\n\n body, err := httpUtil.SendRequest(websiteURL, \"GET\", httpUtil.Header{}, 10*time.Second)\n ...\n}\n```\n\n`TrimURL` strips whitespace and slashes. It does not parse the URL or look at the host. Whatever string the caller sent is what `SendRequest` will fetch.\n\n`SendRequest` itself, in v4.2.1, looks like this:\n\n```go\n// internal/util/http/http.go (v4.2.1)\nfunc SendRequest(url, method string, customHeader Header, timeout ...time.Duration) ([]byte, error) {\n clientTimeout := 2 * time.Second\n if len(timeout) > 0 {\n clientTimeout = timeout[0]\n }\n\n // 自定义 HTTP 客户端,忽略 TLS 证书验证\n client := &http.Client{\n Timeout: clientTimeout,\n Transport: &http.Transport{\n TLSClientConfig: &tls.Config{\n InsecureSkipVerify: true, // 忽略证书验证\n },\n },\n }\n ...\n}\n```\n\nThe Chinese comment on the client translates to \"custom HTTP client, ignore TLS certificate verification.\" The inline comment on the field translates to the same thing. Outbound HTTPS from Ech0's server in v4.2.1 trusted any TLS peer, valid certificate or not. The two comments are testimony: the developer was aware enough of the choice to label it twice.\n\n## What \"Safe\" adds\n\nThe April 1, 2026 commit titled `feat(router, http): implement SSRF protection and route adjustment` adds 178 lines to `http.go`. None of them rewrite `SendRequest`. They define `SendSafeRequest` next to it:\n\n```go\n// internal/util/http/http.go (v4.2.8)\nfunc SendSafeRequest(url, method string, customHeader Header, timeout ...time.Duration) ([]byte, error) {\n if err := ValidatePublicHTTPURL(url); err != nil {\n return nil, err\n }\n ...\n client := &http.Client{\n Timeout: clientTimeout,\n Transport: &http.Transport{\n TLSClientConfig: &tls.Config{\n MinVersion: tls.VersionTLS12,\n },\n DialContext: SecureDialContext(clientTimeout),\n },\n CheckRedirect: func(req *http.Request, via []*http.Request) error {\n if len(via) >= maxSafeRedirects {\n return errors.New(\"重定向次数过多\")\n }\n return ValidatePublicHTTPURL(req.URL.String())\n },\n }\n ...\n}\n```\n\n`ValidatePublicHTTPURL` rejects anything that is not `http` or `https`, rejects URLs with embedded user-info, rejects `localhost` and its docker aliases (`host.docker.internal`, `gateway.docker.internal`, `*.localhost`), and rejects any parsed-IP host inside fourteen reserved CIDR ranges:\n\n```\n0.0.0.0/8 10.0.0.0/8 100.64.0.0/10\n127.0.0.0/8 169.254.0.0/16 172.16.0.0/12\n192.168.0.0/16 198.18.0.0/15 224.0.0.0/4\n240.0.0.0/4 ::/128 ::1/128\nfe80::/10 fc00::/7 ff00::/8\n```\n\n`SecureDialContext` is the second layer. It connects with a normal dialer, then re-inspects the `*net.TCPAddr` of the resolved peer and closes the connection if its IP falls in the same blocked set. This is the defense against DNS rebinding, where a hostname resolves to a public IP at validation time and a private IP at dial time. The IP check runs after the kernel completes the socket, not just after `url.Parse`.\n\nThe response body is also bounded: `readBodyWithLimit` caps it at 1 MiB. Redirects are capped at three, and the `CheckRedirect` callback re-runs `ValidatePublicHTTPURL` on each target so a `https://attacker/redirect-to-169.254.169.254` cannot smuggle the metadata IP through.\n\nThe same commit also rewrites the body of the original `SendRequest`:\n\n```diff\n-\t\t// 自定义 HTTP 客户端,忽略 TLS 证书验证\n+\t\t// 自定义 HTTP 客户端\n \t\tclient := &http.Client{\n \t\t\tTimeout: clientTimeout,\n \t\t\tTransport: &http.Transport{\n \t\t\t\tTLSClientConfig: &tls.Config{\n-\t\t\t\t\tInsecureSkipVerify: true, // 忽略证书验证\n+\t\t\t\t\tMinVersion: tls.VersionTLS12,\n \t\t\t\t},\n \t\t\t},\n \t\t}\n```\n\n`SendRequest` keeps its name and signature. Its body is now strictly safer than it was. It still does no URL validation.\n\n## The tests name the threat model the developer knew\n\nThe same commit adds `internal/util/http/http_security_test.go`. The cases are exhaustive about what `ValidatePublicHTTPURL` is supposed to refuse:\n\n```go\n{name: \"reject_loopback_ipv4\", rawURL: \"http://127.0.0.1\", wantErr: true},\n{name: \"reject_loopback_ipv6\", rawURL: \"http://[::1]\", wantErr: true},\n{name: \"reject_localhost\", rawURL: \"http://localhost\", wantErr: true},\n{name: \"reject_private_ipv4\", rawURL: \"http://10.0.0.1\", wantErr: true},\n{name: \"reject_link_local_metadata\", rawURL: \"http://169.254.169.254\", wantErr: true},\n{name: \"reject_docker_host_alias\", rawURL: \"http://host.docker.internal\", wantErr: true},\n{name: \"reject_url_with_userinfo\", rawURL: \"http://admin:pass@example.com\", wantErr: true},\n{name: \"reject_ipv6_link_local\", rawURL: \"http://[fe80::1]\", wantErr: true},\n```\n\nA separate test, `TestSecureDialContext_blocks_loopback`, starts a real `httptest.NewServer` on `127.0.0.1`, dials it through `SecureDialContext`, and asserts the dial returns an error rather than a connection. The DNS-rebinding defense is exercised as code, not as a comment.\n\nThe test names enumerate the threat model the developer brought to the safer function. `reject_link_local_metadata` is AWS IMDS, GCP, Azure metadata, all the same `169.254.169.254` address. `reject_docker_host_alias` is the case where the Ech0 container is on a docker network and the attacker tries to reach the host through the magic aliases. Each test is documentation of an attack the developer was thinking about. None of them apply to `SendRequest`, because `SendRequest` does not call `ValidatePublicHTTPURL`.\n\n## The patch is three substitutions across three files\n\nThe visible behavior change in v4.2.8 is three lines:\n\n1. `internal/router/common.go`: `PublicRouterGroup` becomes `AuthRouterGroup`. The endpoint requires authentication.\n2. `internal/service/common/common.go`: `SendRequest` becomes `SendSafeRequest`. The service uses the validated client.\n3. `internal/util/http/http.go`: `InsecureSkipVerify: true` becomes `MinVersion: tls.VersionTLS12`. The unsafe primitive stops trusting any certificate.\n\nThe other 178 lines added to `http.go` are additive. They define the new validation function, the new dial context, the body-limit helper, and the safer `SendSafeRequest` client. None of them replace `SendRequest`. None of them gate it. Anyone who calls `SendRequest` after April 1 gets a TLS-verifying outbound HTTP client with no URL validation and no DNS-rebinding defense.\n\nThe patch is correct for the call site it addresses. The component is not.\n\n## The advisory is wrong about which versions are fixed\n\nThe GHSA published April 1 lists \"Affected versions: <= 4.2.1\" and \"Patched version: 4.2.8\". The two ranges are not consistent. If the patch landed in 4.2.8, then 4.2.2, 4.2.3, 4.2.4, 4.2.5, and 4.2.7 contain the bug. They do; the diff above applies cleanly across the six intermediate tags. NVD's record is correct: \"Prior to 4.2.8.\"\n\nOperators reading the GHSA and concluding they were patched at 4.2.5 were not. The PoC author noticed the inconsistency and recorded it in the lab README. The advisory has not been corrected.\n\n## Thirty-two days later, the other caller\n\n`SendRequest` had two call sites in v4.2.1. The April 1 commit switched one. The other was `fetchPeerConnectInfo` in `internal/service/connect/connect.go`, which polls peer Ech0 instances to populate the public `/api/connects/info` endpoint. Peer URLs are stored at admin time via `POST /addConnect`. The public endpoint reads them and triggers outbound requests on every fetch. The store-now, fetch-later split means the admin trust boundary on the write is divorced from the public trigger on the read.\n\nOn May 3, 2026, commit `091d26d2 fix(connect): block SSRF in peer info fetch + AddConnect URL validation` lands. The commit message:\n\n> GHSA-8mc6-xjpr-h98x: fetchPeerConnectInfo used SendRequest with no URL validation, allowing admin-added peer URLs to target private networks and cloud metadata (169.254.169.254, kubernetes.default.svc, etc.). Once stored, the public /api/connects/info endpoint would trigger the outbound request.\n\nThe fix is one line: switch the call from `SendRequest` to `SendSafeRequest`. The same one line that fixed CVE-2026-35037, on a different file, thirty-two days later. The GHSA-8mc6 advisory summary describes the substrate directly: \"by leveraging an unsafe HTTP utility function instead of the safer alternative with URL validation.\"\n\nThis is the Design Debt Driver pattern. The component (`internal/util/http/http.go`) is the substrate. It exports `SendRequest` and `SendSafeRequest` side by side, with no mechanism that forces callers to pick the safer one. The first SSRF was a one-line fix at one call site. The second SSRF was a one-line fix at the call site the first fix missed. The substrate did not move between them.\n\nThe April patch added the safer sibling. The May patch picked it the second time. Whether the next outbound-HTTP feature picks it on the first try depends on whoever next writes one of these lines reading the function name carefully enough to notice that there are two.\n\nPoC: [fineman999/POC_CVE-2026-35037](https://github.com/fineman999/POC_CVE-2026-35037)","closing_line":"`SendRequest` and `SendSafeRequest` are both still in Ech0's httpUtil. The contract is the word in the middle of the name.","hook_md":"The fix for CVE-2026-35037 changes one word in Ech0's `GetWebsiteTitle` service. `SendRequest` becomes `SendSafeRequest`. The same commit adds a new function next to the old one, validates URLs against fourteen reserved CIDR ranges, restores TLS certificate verification that was turned off, and moves the endpoint behind authentication. Thirty-two days later, GHSA-8mc6-xjpr-h98x lands on the other caller of that same unsafe function.","post_id":371,"slug":"ech0-cve-2026-35037-one-of-two-callers","title":"CVE-2026-35037: Ech0's Patch Switched One of Two Callers of SendRequest","type":"initial","unreadable_sentence":"The fix for CVE-2026-35037 switched one of `SendRequest`'s two callers. The other came back as GHSA-8mc6-xjpr-h98x thirty-two days later."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCav3oUgAKCRDeZjl4jgkQ Jr0xAPwILPIif1ddwKdrDv0WyhUNiyfkQOpkjd3HwC1YLfjpkgD/XeDOnnxsCFtb nQ7CMTW4CIHn1MH4gzhmiYnAnicXagE= =7Zhx -----END PGP SIGNATURE-----