Summary
Chainlit versions prior to 2.9.4 expose a server-side request forgery (SSRF) issue in the /project/element update flow when the SQLAlchemy data layer backend is used.
An authenticated client can supply a user-controlled URL that the server will fetch via HTTP, enabling requests to internal services or cloud metadata endpoints and storing the responses through the configured storage provider.
Affected context
The vulnerability arises in Chainlit deployments that:
- Use the SQLAlchemy data layer backend for element storage
- Allow authenticated users to create or update Elements via the
/project/elementflow - Permit a user-controlled
urlfield to be passed into element creation logic
In this context, the Chainlit server performs outbound HTTP GET requests based on the user-controlled URL without sufficient validation or restriction, potentially reaching internal-only hosts or cloud metadata services accessible from the server's network position.
Exploit preconditions
- Attack surface: Chainlit HTTP API, specifically Element creation/update endpoints (e.g.,
/project/element) when SQLAlchemy backend is configured. - Required access: Authenticated client able to submit or update Element definitions including a
urlfield. - Trigger point: Submitting an Element whose
urlattribute points to an attacker-chosen target host or endpoint. - Why exploitation is possible: The element creation logic issues outbound HTTP GET requests to the provided URL without enforcing robust allowlists, network segmentation checks, or metadata endpoint protections, effectively allowing user-controlled server-side requests.
Why this happens
This issue stems from treating user-controlled URLs as trusted destinations for server-initiated HTTP requests within the SQLAlchemy element creation flow.
The backend logic interpolates a URL provided by an authenticated client directly into an outbound HTTP GET operation, without applying strict validation, host restriction, or network-layer isolation.
This pattern corresponds to CWE-918: Server-Side Request Forgery (SSRF), where an attacker can abuse the server's network privileges to reach internal or otherwise inaccessible endpoints by controlling request targets.
Potential impact
- Access to internal HTTP services that are not exposed publicly but are reachable from the Chainlit server.
- Retrieval of cloud provider instance metadata, which may include tokens, credentials, or configuration secrets.
- Discovery of internal network structure and services through response content or error messages.
- Leveraging stored responses to exfiltrate sensitive data via the configured storage provider.
- Potential pivoting to further attacks if internal services expose administrative or management interfaces over HTTP.
General mitigation guidance
Effective mitigation focuses on reducing trust in user-supplied URLs and constraining where the server can connect:
- Apply strict allowlists of permitted domains or endpoints for any server-initiated HTTP fetch operations, rejecting all others by default.
- Disallow or carefully constrain direct use of user-controlled URLs in backend logic; where URLs must be accepted, validate scheme, host, and port against known-safe patterns.
- Block access to link-local and internal-only addresses (e.g.,
169.254.169.254, RFC1918 ranges, loopback, and Unix socket-based HTTP) at the application layer and, where possible, at the network level. - Isolate services performing outbound fetches into restricted network segments with minimal reachable internal resources.
- Store only the minimal necessary subset of fetched data, and avoid persisting highly sensitive metadata or large unvalidated responses.
How teams detect issues like this
Organizations can look for SSRF indicators and risky patterns using:
- Static analysis rules that flag HTTP client usage where request targets are derived from user-controllable fields (e.g., request parameters or JSON body fields named
url,uri,endpoint). - Code review checklists that require reviewers to verify that all outbound HTTP requests have domain restrictions, scheme checks, and address filtering.
- Runtime monitoring of outbound egress traffic from Chainlit servers, looking for:
- Connections to link-local or metadata IPs (e.g.,
169.254.169.254). - Unexpected access to internal private ranges (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16). - Web application firewall (WAF) or egress firewall policies that log and optionally block suspicious destinations from the application's network perimeter.
- Automated security review tools integrated into CI/CD, configured to detect unvalidated URL usage and SSRF-prone patterns in Python/SQLAlchemy-based components.

