Summary
prompts.chat contained a server-side request forgery (SSRF) weakness in the Fal.ai media status polling logic that allowed authenticated users to control outbound HTTP requests via a token parameter.
By supplying attacker-controlled URLs, a user could force the backend to send requests with its own Authorization header, potentially leaking the FAL_API_KEY, probing internal services, and abusing the victim's Fal.ai account.
Affected context
This vulnerability appears in prompts.chat's backend integration with Fal.ai, specifically in the media status polling endpoint that makes HTTP requests on behalf of users.
The affected context is any deployment where:
- The backend fetches Fal.ai media status by calling a URL derived from user-controlled input (the
tokenparameter). - The backend attaches a Fal.ai Authorization header containing a FAL_API_KEY.
- There is no strict validation, allow‑listing, or normalization of the destination URL.
Under these conditions, attacker-supplied URLs can redirect the backend's HTTP client to arbitrary internal or external endpoints.
Exploit preconditions
- Attack surface: Backend HTTP client used for Fal.ai media status polling.
- Required access: Authenticated access to prompts.chat features that accept a
tokenparameter used in Fal.ai polling. - Trigger point: Submission of a crafted request where the
tokenparameter, directly or indirectly, controls the full or partial polling URL. - Why exploitation is possible:
- The application trusts user-controlled data to construct outbound URLs.
- There is no sufficient URL validation, scheme restriction, or host allow‑list.
- The backend automatically includes sensitive headers (e.g.,
Authorization: Bearer FAL_API_KEY) in these requests, even when directed to attacker-controlled endpoints.
Why this happens
The core issue is a classic server-side request forgery pattern: the server uses untrusted user input to construct outbound HTTP requests without constraining the destination.
This maps to CWE-918: Server-Side Request Forgery (SSRF), where the server becomes a proxy that attackers can coerce into contacting arbitrary URLs.
In this case, the Fal.ai media status polling logic likely:
- Accepted a
tokenvalue that influenced the status endpoint's URL. - Passed that URL directly into an HTTP client.
- Automatically attached the Fal.ai Authorization header containing the backend's FAL_API_KEY.
Because the server failed to enforce strict controls on the URL (host, scheme, path), attackers could point it at endpoints they control or internal services, and capture the outgoing Authorization header or observe the responses.
Potential impact
- Theft of the backend's Fal.ai FAL_API_KEY via responses from attacker-controlled endpoints.
- Unauthorized use of the victim's Fal.ai account, including running jobs, consuming credits, or accessing associated resources.
- Internal network scanning and probing using the application server as a pivot.
- Access to internal-only HTTP services that are otherwise not directly exposed to users.
- Potential chaining with other vulnerabilities (e.g., internal admin panels or metadata endpoints) for further compromise.
General mitigation guidance
Effective mitigation focuses on restricting where and how the backend can make outbound HTTP requests and reducing the exposure of sensitive headers:
- Constrain destination hosts:
- Use a strict allow‑list of known Fal.ai API hostnames and enforce exact matches.
- Reject or normalize user-supplied input so it can only influence safe URL components (e.g., path segments or IDs), not the scheme, host, or port.
- Validate and sanitize URLs:
- Enforce HTTPS.
- Block non-HTTP schemes and private or loopback IP ranges after DNS resolution.
- Normalize and re-parse URLs server-side before use.
- Decouple sensitive headers from user-controlled destinations:
- Only attach Authorization headers when the resolved host is explicitly trusted and expected.
- Use separate HTTP client configurations for internal/partner APIs vs. user-specified resources.
- Apply least privilege and compartmentalization:
- Use scoped Fal.ai API keys with the minimal permissions required.
- Store API keys in secure secrets management systems and limit their reuse across components.
- Design for safe-by-default integrations:
- Treat integration tokens as opaque identifiers, not as raw URLs.
- Have the server construct URLs from fixed templates and validated IDs, rather than accepting full URLs from the client.
How teams detect issues like this
Detection can combine code-centric analysis with behavioral and operational monitoring:
- Static analysis and code review:
- Search for outbound HTTP calls where the URL is derived from request parameters (e.g.,
token,callback,url). - Flag patterns where user-controlled input influences the scheme, host, or port of HTTP requests.
- Identify HTTP client configurations that always attach sensitive headers (Authorization, API keys) regardless of destination.
- Configuration and policy checks:
- Enforce security policies that forbid arbitrary outbound requests in sensitive services.
- Use linters or custom CI checks to ensure URL construction follows an allow‑list or template-based pattern.
- Runtime and logging analysis:
- Log outbound HTTP destinations, including resolved IPs, and alert on unexpected hosts or private/loopback ranges.
- Monitor for anomalous patterns like many distinct external hosts being contacted through the Fal.ai polling path.
- Automated tooling:
- Apply API security testing tools or DAST scanners that probe endpoints for SSRF by sending controlled URLs and observing backend behavior.

