Details
POST /api/esri HTTP/1.1
Host: cloudtak.example.org
Content-Type: application/json
{ "url": "http://169.254.169.254/latest/meta-data/arcgis/rest" }
Returns 403 Authentication Required (from Auth.is_auth → api/lib/auth.ts:118). The SSRF is reachable by any authenticated user but not by an anonymous one.
E2E reproduction (sink path against a controlled internal victim)
Because exercising the real route against a public cloud metadata endpoint is not something to do against third-party infrastructure, the sink was reproduced against a local internal-only victim using the same `fetch` import (`@tak-ps/etl`) and the verbatim `EsriBase.sniff()` + `fetchVersion()` logic the route uses. The harness models the route handler exactly: it new URL()s the user input, runs sniff(), then fetch()s — with isSafeUrl deliberately *not* called (matching shipped behavior), and a toggled control branch that calls it (matching the basemap guard).
Victim (victim.mjs) — an internal-only service on 127.0.0.1:9099 returning a secret JSON body:
[victim] internal service listening on 127.0.0.1:9099
[victim] HIT GET /arcgis/rest?f=json from 127.0.0.1
Harness output (esri_ssrf_e2e.mjs), user-supplied URL http://127.0.0.1:9099/arcgis/rest:
[VULN/no-guard] route returned full internal body:
{
"type": "SERVER",
"base": "http://127.0.0.1:9099/arcgis/rest",
"upstreamBody": {
"currentVersion": "11.4",
"internal-only": true,
"aws-metadata-simulated": {
"iam": { "role": "cloudtak-prod-instance-role", "AccessKeyId": "ASIA_FAKE_INTERNAL_KEY_DO_NOT_USE" }
},
"note": "If you can read this from a user-supplied URL, that is SSRF (full-read)."
}
}
[CONTROL/guarded] blocked as expected: Blocked URL: blocked IP address: 127.0.0.1
And isSafeUrl confirms it *would* block the metadata / loopback targets if it were called on this path:
http://169.254.169.254/latest/meta-data/ => {"safe":false, ... "reason":"blocked IP address: 169.254.169.254"}
http://127.0.0.1:9999/ => {"safe":false, ... "reason":"blocked IP address: 127.0.0.1"}
http://localhost/ => {"safe":false, ... "reason":"blocked hostname: localhost"}
So: with the shipped (no-guard) code the request reaches the internal victim and the full internal body is returned; with the basemap-style isSafeUrl guard the same request is blocked. (A full container OOM-style demonstration of reading real cloud metadata is intentionally not performed against live infrastructure; the victim-host reproduction is the honest, self-contained equivalent of the route's fetch path.)
Root cause
Two compounding gaps:
- No IP/DNS classification before fetch.
api/lib/esri.tsimports the unguardedfetchfrom@tak-ps/etland calls it with a URL derived directly from user input in everyEsriProxy*method and inEsriBase.fetchVersion()/generateToken(). Nothing resolves the hostname and rejects private / loopback / link-local addresses. The repository already depends on@tak-ps/node-safeurl(isSafeUrl) precisely for this, and uses it inapi/routes/basemap.ts,api/routes/task.ts, andapi/lib/control/video-service.ts— but the guard was never added to the ESRI route family or to the ESRI library. This is an incomplete migration: the SafeURL hardening (PR #1468) covered basemap/task/video but left/api/esri*andapi/lib/esri.ts(including the ESRI sub-branch of basemap import) unprotected.
- `sniff()` validates the wrong thing. The only inspection the URL receives before being fetched is
EsriBase.sniff(), which pattern-matches the *pathname* for/rest,/arcgis/rest, or/sharing/rest. It never looks at the host, so an attacker simply appends/rest(or/arcgis/rest) to an internal URL and it is accepted and fetched.
Impact
- CWE-918 Server-Side Request Forgery, full-read.
- Cloud credential theft: reading
http://169.254.169.254/latest/meta-data/iam/security-credentials/...(IMDSv1) yields the instance role's temporary AWS credentials, which an attacker can use against the deployment's cloud account. - Internal network enumeration and data exfiltration: any host:port reachable from the CloudTAK server (loopback admin ports, VPC-internal services, databases with HTTP interfaces, link-local) can be probed and, where the response is JSON-ish, read in full via the reflected response body / error string.
- Privilege required: any authenticated user with any token (
anyResources: true) — not limited to administrators. Unauthenticated requests are rejected (403), so this requires a valid account but no special role.
Fix
Centralize the existing isSafeUrl guard inside the ESRI library so every /api/esri* route and the ESRI sub-branch of basemap import are covered by one chokepoint, mirroring the guard already used in basemap.ts:
- Add an async URL-classification step that runs
isSafeUrl(...)and throwsBlocked URL: <reason>for any URL that resolves to a private/loopback/link-local address, before the firstfetchinEsriBase(e.g. inEsriBase.from()and a guarded constructor/init path, so bothnew EsriBase(...)+ later proxy calls andEsriBase.from(...)are covered). - Preserve the existing
process.env.StackName !== 'test'test-mode skip used elsewhere so the test suite is unaffected.
Because all six routes funnel through EsriBase / the EsriProxy* classes in api/lib/esri.ts, guarding the library is sufficient and avoids re-introducing the same per-route omission. A reference patch implementing exactly this (guard added to the ESRI library + applied on the route entry points, matching the basemap pattern) is provided as a pull request from a private fork.
Disclosure
- Reported by tonghuaroot.
- Credit: tonghuaroot only.
---
Reference fix PR (private advisory fork): https://github.com/dfpc-coe/CloudTAK-ghsa-r95q-fp26-h3hc/pull/1 — commit ff6dd1d9, centralizing isSafeUrl inside api/lib/esri.ts (safeFetch wrapper + EsriBase.assertSafe).