feat(share-links): scrub the share token from logs and harden the /c edge

Register the `/c/` prefix in `PATH_SECRET_PATHS` so the raw `hls_` clinician
share token, which rides as the trailing path segment, is rewritten to
[REDACTED] in `http.path` / `http.route` before any Wide Event or GlitchTip
report leaves the process — the same posture as the Withings webhook path
secret. The resolve path never logs, throws, or annotates the raw token.

Defend the share surface at the edge irrespective of what the RSC emits: the
proxy now sets `Cache-Control: no-store`, `X-Robots-Tag: noindex, nofollow`,
and `Referrer-Policy: no-referrer` on `/c/` responses, so no downstream proxy
caches a scoped record, no crawler indexes the token, and the token-bearing
URL is not leaked in an outbound `Referer`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.8 committed 2026-06-04 01:39:58 +02:00
1 parent 5917bba61c
commit f4629a17d6
3 files changed
+58 -4

No files matched your search

+20
View File
@@ -237,6 +237,26 @@ export function proxy(request: NextRequest) {
"Permissions-Policy",
"camera=(), microphone=(), geolocation=()",
);
// v1.11.0 (Epic C, C6) — the public clinician share view at `/c/<token>`
// is a scoped health record authenticated by an unguessable bearer token
// in the path. Defend it at the edge regardless of what the RSC emits:
// - `Cache-Control: no-store` so no shared proxy / CDN ever retains a
// scoped record (the page is `force-dynamic`, but that governs Next's
// cache, not a downstream intermediary).
// - `X-Robots-Tag: noindex, nofollow` as the header peer of the page's
// `robots` meta — a crawler that never parses the document still obeys
// the header, and the token must never reach a search index.
// - `Referrer-Policy: no-referrer` so the token-bearing URL is not
// leaked in the `Referer` of any outbound navigation from the page.
if (pathname.startsWith("/c/")) {
response.headers.set(
"Cache-Control",
"no-store, no-cache, must-revalidate",
);
response.headers.set("X-Robots-Tag", "noindex, nofollow");
response.headers.set("Referrer-Policy", "no-referrer");
}
// COOP isolates this BrowsingContextGroup from cross-origin popups,
// closing the Spectre-class side-channel surface a stray
// `window.opener` reference would otherwise carry. CORP narrows the