Summary
A server-side request forgery (SSRF) vulnerability in ChatGPTNextWeb NextChat's Artifacts API allows attackers to abuse the storeUrl function to make the server initiate arbitrary outbound HTTP requests.
By manipulating the id argument, a remote attacker can pivot through the server to reach internal or protected resources that are not directly exposed to the internet.
Affected context
The issue occurs in deployments of ChatGPTNextWeb NextChat (up to 2.16.1) where the Artifacts Endpoint (app/api/artifacts/route.ts) is exposed and processes user-controlled input through the storeUrl function.
The vulnerability is present when the id parameter is accepted from client input and used to construct or influence outbound requests without strong validation or restriction of target hosts, schemes, or IP ranges.
Any environment where the application can connect to internal services, cloud metadata endpoints, or other non-public infrastructure is at elevated risk.
Exploit preconditions
- Attack surface: Publicly exposed Artifacts API endpoint (
/api/artifactsor equivalent) reachable over the network. - Required access: Ability to send HTTP requests to the affected endpoint (typically unauthenticated or low-privilege API access, depending on deployment).
- Trigger point: Supplying a crafted
idargument that controls or significantly influences the destination of an outbound HTTP request instoreUrl. - Why exploitation is possible: The server-side logic trusts the user-provided
idvalue when building or resolving URLs, and does not adequately restrict internal IP ranges, non-HTTP(S) schemes, or sensitive endpoints, allowing the server to act as a proxy to unintended network targets.
Why this happens
The vulnerability stems from insufficient validation and sanitization of user-influenced URL parameters before they are used in server-initiated HTTP requests.
In the storeUrl function, the id argument is treated as a trustworthy component in constructing or resolving a URL, effectively delegating target selection to the client.
This maps to CWE-918: Server-Side Request Forgery, where an application permits attackers to make arbitrary network requests from the server to internal or external systems by controlling URL-like input.
The core insecure pattern is using client input directly to drive server-side HTTP requests without enforcing strict allow-lists, scheme checks, IP filtering, or network egress controls.
Potential impact
- Access to internal web services that are not exposed to the public internet
- Interaction with cloud provider metadata services, potentially leaking credentials or tokens
- Port scanning or service discovery within the internal network from the application host
- Bypassing IP-based access controls or network segmentation by tunneling through the application server
- Pivoting into more sensitive systems, enabling follow-on attacks such as data exfiltration or environment reconnaissance
General mitigation guidance
Effective mitigation focuses on constraining where the server is allowed to connect and reducing client control over outbound requests:
- Enforce strict allow-lists for outbound destinations (domains, paths, and protocols) used by artifact-related requests, rejecting any value outside expected patterns.
- Validate and normalize user-influenced URL components before use: require HTTPS, reject ambiguous encodings, and disallow redirects to unapproved hosts.
- Block access to internal IP ranges (e.g., RFC1918, link-local, loopback) and metadata service addresses at the application layer and, where possible, at the network layer.
- Decouple user input from raw URLs: map user-supplied identifiers to predefined, server-side configured endpoints instead of treating them as full or partial URLs.
- Apply least-privilege networking for the application runtime, limiting egress to only the domains and ports necessary for normal operation.
How teams detect issues like this
To identify and monitor SSRF risks in similar code paths, organizations can:
- Use static analysis rules to detect patterns where user input flows into HTTP client calls (e.g.,
fetch,axios,http.request) without prior validation or allow-list checks. - Add code review checklists that flag any new feature where URLs or hosts are derived from request parameters, query strings, or body fields.
- Implement runtime logging and anomaly detection for outbound HTTP requests, such as alerts for attempts to reach internal IP ranges, metadata services, or unexpected domains.
- Leverage automated security testing tools (DAST and SAST) that specifically probe for SSRF by injecting internal IPs, reserved hostnames, or metadata endpoints into URL parameters.

