templates: escape query value in ping page

elem-go does not escape attribute values, so the raw query reaches
the rendered HTML verbatim. Pre-escape with html.EscapeString to prevent
reflected XSS.

Updates #3157
This commit is contained in:
Kristoffer Dalby 2026-04-17 05:46:44 +00:00
parent 3a4af8cf87
commit f3eb9a7bba
3 changed files with 28 additions and 2 deletions

View file

@ -361,7 +361,6 @@ func (h *Headscale) debugHTTPServer() *http.Server {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
//nolint:gosec // elem-go auto-escapes all attribute values; no XSS risk.
_, _ = w.Write([]byte(templates.PingPage(query, result, nodes).Render()))
}))