Summary
A Server-Side Request Forgery (SSRF) flaw in the clerkFrontendApiProxy helper of the Clerk JavaScript backend libraries can be abused to redirect backend proxy requests to arbitrary attacker-controlled URLs.
By crafting a malicious request path, an unauthenticated attacker can trick the application into sending its Clerk-Secret-Key to a remote server, risking full account takeover and downstream compromise wherever that secret is trusted.
Affected context
This vulnerability appears in Node.js applications that:
- Integrate Clerk authentication using the affected
@clerk/backendproxy function, often via the@clerk/hono,@clerk/express, or@clerk/fastifybindings - Rely on
clerkFrontendApiProxyto forward frontend-originated API calls to Clerk services - Construct the proxy target URL using request parameters or paths that are not strictly constrained to the intended Clerk domain
The issue is observable where the backend has network egress and the Clerk-Secret-Key is available to the runtime, allowing the proxy to forward requests, including this secret, to arbitrary endpoints.
Exploit preconditions
- Attack surface: Public HTTP endpoints that expose Clerk's frontend API proxy (e.g., routes using
clerkFrontendApiProxy). - Required access: No prior authentication is required; an attacker only needs network access to the affected endpoint.
- Trigger point: Submission of a specially crafted HTTP request whose path or query parameters cause the proxy helper to build a request to an attacker-controlled origin instead of the legitimate Clerk API.
- Why exploitation is possible: The proxy logic implicitly trusts client-controlled URL components when constructing the outbound request and does not strictly validate or pin the destination host to the Clerk infrastructure, enabling SSRF and secret exfiltration.
Why this happens
The core issue is a missing or insufficient validation of the outbound request target in a server-side proxy function that acts on partially user-controlled input.
In the affected Clerk backend libraries, clerkFrontendApiProxy uses data derived from the incoming request path to build the URL for a server-to-server call. Because the implementation does not comprehensively restrict the host and scheme to trusted Clerk endpoints, an attacker can manipulate the request path to redirect the proxy to an arbitrary URL. During this proxying operation, sensitive authentication material (such as the Clerk-Secret-Key) is included in the outbound request, turning the SSRF condition into a secret exfiltration vector. This aligns with CWE-918: Server-Side Request Forgery, where a server makes unintended network requests due to untrusted input driving request construction.
Potential impact
- Exposure of the
Clerk-Secret-Keyto attacker-controlled infrastructure - Full compromise of Clerk authentication for the affected application (e.g., session manipulation, user impersonation, or account takeover) wherever the secret is accepted
- Abuse of the compromised secret to create, modify, or delete authentication-related resources via Clerk APIs
- Pivoting into broader system or organizational compromise if the same secret is re-used across environments or tied to highly privileged accounts
- Expanded SSRF blast radius, where the proxy could be abused to scan internal services or interact with otherwise unreachable endpoints
General mitigation guidance
Effective mitigation centers on strict destination control, defensive proxy design, and secret handling hardening:
- Pin proxy targets to trusted domains: Ensure any backend proxy helper constructs outbound URLs using fixed, hardcoded hosts and schemes (e.g., preconfigured Clerk API base URL) rather than dynamic data derived from request paths or headers.
- Normalize and validate paths: Sanitize and normalize any path information used in proxying. Reject paths that contain full URLs, protocol-relative forms, encoded hosts, or path traversal patterns that could alter the final target.
- Avoid passing secrets automatically: Minimize the automatic inclusion of highly sensitive secrets in generic proxy helpers. Prefer narrowly scoped tokens (e.g., per-request or per-tenant tokens) with least privilege instead of long-lived global secrets.
- Enforce outbound network restrictions: Use network policies, firewalls, or egress controls to restrict servers so they can only reach known Clerk endpoints (and other intended third-party services).
- Apply principle of least privilege: Run application components with minimal permissions and separate duties so that compromise of one secret or component does not automatically lead to full system takeover.
- Centralize proxy logic: Keep proxy and forwarding logic in a small, well-reviewed module to simplify auditing and reduce the chance of inconsistent validation.
How teams detect issues like this
Detection generally combines code-level analysis with behavioral monitoring:
- Static analysis and code scanning:
- Search for custom proxy helpers or middleware that construct outbound URLs using request path, query, or headers.
- Flag patterns where environment secrets (such as
Clerk-Secret-Key) are attached to outbound requests whose destination is not strictly hardcoded or domain-pinned. - Add rules to detect concatenation of user input into URLs and review all such call sites for SSRF risk.
- Code review signals:
- Proxy functions that accept arbitrary paths or URLs from the client without whitelisting domains.
- Middleware that forwards all headers or automatically attaches secrets to proxied requests.
- Any logic that interprets path segments as parts of a URL authority or scheme.
- Runtime and log monitoring:
- Monitor outbound HTTP requests from backend services, especially those carrying authentication headers or secrets, for destinations outside expected Clerk domains.
- Implement anomaly detection on egress to identify unusual destinations, protocols, or spikes in outbound traffic.
- Use application logs to detect suspicious use of proxy endpoints, such as requests with full URLs in path components.
- Security testing and hardening:
- Incorporate SSRF tests into regular penetration testing and CI-based security checks, including attempts to force backend proxies to call internal IPs or external test endpoints.

