Skip to content

security(ui): escape perf dashboard values (raw slow-query path) in perf.js #392

Closed

Description

@dborup

Found during the review of #373 (#333, merged as 8a26a339). It is a follow-up to the #333 XSS work and was deliberately kept out of #373's scope.

Problem

public/perf.js (around lines 324, 334 and 345) interpolates perf data into HTML without escaping. One of those values is SlowQuery.Path, which is set to the raw r.URL.Path with no normalisation (cmd/server/routes.go ~509). By contrast, the endpoint key a few lines above is normalised to the mux route template.

Verified in a browser [T]: injecting a hostile endpoint key and slow-query path into the /api/perf response renders injected <img> elements on #/perf, and onerror fires.

Exploitability (narrower than the raw sink suggests)

To be recorded, a request must route under /api/ and take longer than 100 ms. Five hostile /api/... paths sent to a local server all returned 404 quickly. The recorded key collapsed to /api/, and no hostile key or slow query was stored. No end-to-end exploit was demonstrated, but this should not rely on timing.

Required work

  • Escape every interpolated perf value in public/perf.js. Use escapeHtml for text and escapeAttr for attributes, or textContent.
  • Consider normalising SlowQuery.Path server-side, for example to the route template plus a truncated, sanitised raw path.
  • Add hostile-string unit/E2E tests for the perf dashboard, and run them only against a local server.
  • Make sure scripts/check-xss-sinks.sh covers these sinks.

Activity

  1. added 2 commits that reference this issue on Oct 13, 2026
  2. dborup commented on Oct 13, 2026

    @dborup
    OwnerAuthor

    Fixed by #394 (merged as ce29f5dca51e9b52080dcbef1d9e2ee5b52867f3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions