api/ping: allowlist hosts and block redirects to close SSRF/LAN-scan vector

This commit is contained in:
Martin Dvořák 2026-09-24 20:43:41 +00:00
commit ea757595b0
3 changed files with 67 additions and 7 deletions

View file

@ -116,7 +116,7 @@ site. To force the raw server instead, use `npm run dev:next` (don't point a tun
| --- | --- | --- |
| `/api/heatmap` | `GET` | Proxies the user's contribution heatmap from `git.dvorakmortonxd.dev`. |
| `/api/activities` | `GET` | Fetches the GitDXD activity feed and keeps only the user's own events. |
| `/api/ping?url=…` | `GET` | Health-checks a service. Handles `minecraft://host:port` via mcstatus.io; treats any non-5xx HTTP response as "up". |
| `/api/ping?url=…` | `GET` | Health-checks an **allow-listed** service (the site's own `*.dvorakmortonxd.dev` hosts and the friends' sites). Handles `minecraft://host:port` via mcstatus.io; treats any non-5xx response as "up". Other hosts and schemes are rejected and redirects are never followed, so it can't be used to probe the LAN (SSRF guard). |
## 📁 Project Structure