GitHub Security Advisory: GHSA-cqgf-f4x7-g6wc
Package: github.com/lin-snow/ech0 (GO)
Severity: HIGH (CVSS 7.2)
CWE: CWE-918: Server-Side Request Forgery (SSRF)
Vulnerable versions: < 1.4.8-0[PII_REDACTED]1029-4ca56fea5ba4
Patched in: 1.4.8-0[PII_REDACTED]1029-4ca56fea5ba4

Summary: Ech0: Unauthenticated SSRF in GetWebsiteTitle allows access to internal services and cloud metadata

Details:
## Summary

The `GET /api/website/title` endpoint accepts an arbitrary URL via the `website_url` query parameter and makes a server-side HTTP request to it without any validation of the target host or IP address. The endpoint requires no authentication. An attacker can use this to reach internal network services, cloud metadata endpoints (169.254.169.254), and localhost-bound services, with partial response data exfiltrated via the HTML `<title>` tag extraction.

## Details

The vulnerability exists in the interaction between four components:

**1. Route registration — no authentication** (`internal/router/common.go:11`):
```go
appRouterGroup.PublicRouterGroup.GET("/website/title", h.CommonHandler.GetWebsiteTitle())
```
The `PublicRouterGroup` is created at `internal/router/router.go:34` as `r.Group("/api")` with no auth middleware attached (unlike `AuthRouterGroup` which uses `JWTAuthMiddleware`).

**2. Handler — no input validation** (`internal/handler/common/common.go:106-127`):
```go
func (commonHandler *CommonHandler) GetWebsiteTitle() gin.HandlerFunc {
    return res.Execute(func(ctx *gin.Context) res.Response {
        var dto commonModel.GetWebsiteTitleDto
        if err := ctx.ShouldBindQuery(&dto); err != nil { ... }
        title, err := commonHandler.commonService.GetWebsiteTitle(dto.WebSiteURL)
        ...
    })
}
```
The DTO (`internal/model/common/common_dto.go:155-156`) only enforces `binding:"required"` — no URL scheme or host validation.

**3. Service — TrimURL is cosmetic** (`internal/service/common/common.go:122-125`):
```go
func (s *CommonService) GetWebsiteTitle(websiteURL string) (string, error) {
    websiteURL = httpUtil.TrimURL(websiteURL)
    body, err := httpUtil.SendRequest(websiteURL, "GET", httpUtil.Header{}, 10*time.Second)
    ...
}
```
`TrimURL` (`internal/util/http/http.go:16-26`) only calls `TrimSpace`, `TrimPrefix("/")`, and `TrimSuffix("/")`. No SSRF protections.

**4. HTTP client — unrestricted outbound request** (`internal/util/http/http.go:53-84`):
```go
client := &http.Client{
    Timeout: clientTimeout,
    Transport: &http.Transport{
        TLSClientConfig: &tls.Config{
            InsecureSkipVerify: true,
        },
    },
}
req, err := http.NewRequest(method, url, nil)
...
resp, err := client.Do(req)
```
The client follows redirects (Go default), skips TLS verification, and has no restrictions on target IP ranges.

The response body is parsed for `<title>` tags and the extracted title is returned to the attacker, providing a data exfiltration channel for any response containing HTML title elements.

## PoC

**Step 1: Probe cloud metadata endpoint (AWS)**
```bash
curl -s 'http://localhost:8080/api/website/title?website_url=http://169.254.169.254/latest/meta-data/'
```
If the Ech0 instance runs on AWS EC2, the server will make a request to the instance metadata service. While the metadata response is not HTML, this confirms network reachability.

**Step 2: Probe internal localhost services**
```bash