Skip to content

fix: harden dashboardApiFetch against SSRF (CodeQL #12) - #574

Merged
unjica merged 1 commit into
developfrom
fix/codeql-12-dashboard-api-ssrf
Jul 18, 2026
Merged

unjica merged 1 commit into
developfrom
fix/codeql-12-dashboard-api-ssrf

Conversation

@unjica

@unjica unjica commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes CodeQL alert #12 (js/request-forgery) by hardening dashboardApiFetch / dashboardApiFetchFromCookies URL construction and validating errorGroupId in setErrorResolvedAction.
  • Only relative /api/... paths are accepted; resolved URLs must stay on the fixed API_BASE_URL origin with pathname under /api/.
  • Adds Vitest coverage for accepted paths, rejected SSRF-shaped inputs, and invalid resource ids.

Call-site audit

Area Absolute URLs? User-controlled path? Query strings? Notes
lib/dashboard-api.ts Previously allowed path.startsWith("http") (unused) Path argument from callers Yes (pathAndQuery) Absolute branch removed; resolveDashboardApiUrl is the single gate
app/dashboard/actions.ts No Yes — setErrorResolvedAction(errorGroupId) (alert source); other actions mostly UUID-validated org/project/key ids Some list/settings calls UUID parse + encodeURIComponent on error group id
Detail pages (errors/events/sessions/[id]) No Route params.id interpolated into /api/... Errors detail adds scoped query Hardened by URL resolver (hostname fixed)
List/overview/search/releases/performance No Filter values via URLSearchParams only Yes Paths are fixed /api/... literals + query
Meta/settings helpers (notifications, prefs, webhooks, audit-log, integrations, workspace) No Org/project ids often already UUID-checked + sometimes encodeURIComponent Sometimes Relative /api/... only
app/api/telemetry/[...path]/route.ts No Path allow-listed (sessions/events/errors [+ analytics]) Forwarded search Already restricted before dashboardApiFetch
dashboardApiClientFetch N/A (same-origin proxy) Client path → telemetry proxy Yes Does not call API host directly

Findings: No production call site passed absolute URLs. Redirects are not configured on these fetches (default follow); SSRF risk was path/host injection via unsanitized interpolation, not open redirects. Prefer fix over dismissing the alert.

Test plan

Made with Cursor

Restrict API fetches to relative /api paths on API_BASE_URL and validate
error group ids before path interpolation.

Co-authored-by: Cursor <[email protected]>
@unjica
unjica merged commit dd5ef3c into develop Jul 18, 2026
8 of 9 checks passed
@unjica
unjica deleted the fix/codeql-12-dashboard-api-ssrf branch July 18, 2026 22:49
unjica added a commit that referenced this pull request Jul 18, 2026
FelineFantasy pushed a commit to FelineFantasy/telemetry-tracker that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant