Details
Impact
Unauthenticated remote SSRF, but the path component is constrained to/uploads/attachments/<cuid>-<slug>.<ext> (built from a local-DB lookup
on a slug the attacker already had to know). That constraint plus cuid
uniqueness rules out the cases I originally listed:
- Cloud metadata is _not_ reachable — AWS IMDS (
/latest/meta-data/...), GCP (/computeMetadata/v1/...), and Azure (/metadata/...) all live at fixed paths that don't overlap with/uploads/attachments/.... Same for Redis admin, Elasticsearch, and most internal API surfaces. - Cross-instance data exfiltration is also ruled out. For an internal target (another apos instance, MinIO bucket, etc.) to serve a body at this path, it would need the exact local cuid + slug, which realistically only happens when the target restored / shares the public site's data — in which case the same content is reachable via the front door anyway. Apostrophe also won't construct a pretty URL for archived / restricted media, closing the older-snapshot edge case.
What remains is blind-SSRF residual:
- Network-topology mapping via response-code or response-time differences across internal hosts.
- Banner / version disclosure from verbose reverse-proxy or WAF 404 bodies.
- Bypassing network egress controls — outbound requests originate from the apostrophe server rather than the attacker.
The attack requires only the public pretty-URL endpoint and one
publicly-known file slug, both trivially available in normal CMS
operation.
Recommended fix
Stop deriving the upstream URL from the request Host header. Two
complementary changes:
- In
modules/@apostrophecms/file/index.js(the lines that buildproxyUrl), use a server-trusted absolute base URL (e.g.,apos.baseUrlor the configured site URL) instead ofreq.get('host'):
const proxyUrl = uglyUrl.startsWith('/')
? `${self.apos.baseUrl || req.baseUrl}${uglyUrl}`
: uglyUrl;
- In
lib/stream-proxy.js, enforce a strict origin allowlist (the configured apostrophe base URL + any configured CDN host) before callingfetch. Defence in depth: future callers ofstreamProxycannot accidentally reintroduce the gap.
A regression test that sets Host: 169.254.169.254 (or any non-configured
host) on /files/<slug>.<ext> and asserts the upstream fetch is not
issued / the response is a 4xx would lock this down.