Summary
Crawl4AI's Docker API server exposes unauthenticated endpoints that let attackers redirect LLM API calls and read arbitrary environment variables by abusing request parameters.
By supplying a malicious base_url and using api_token values like env:VARIABLE_NAME, an attacker can exfiltrate provider API keys and secrets such as JWT SECRET_KEY, enabling further compromise and authentication bypass.
Affected context
This vulnerability occurs in Crawl4AI deployments that expose the Docker API server, particularly when the /md, /llm, or /llm/job endpoints are reachable without strong network isolation or authentication.
The issue is relevant in environments where sensitive credentials are stored in environment variables, such as LLM provider API keys, JWT signing secrets, or other server-side tokens.
It becomes especially risky when the Docker API is reachable from untrusted networks (including the broader internet) or from multi-tenant internal environments.
Exploit preconditions
- Attack surface: HTTP(S) access to the Crawl4AI Docker API server.
- Required access: Network-level access to unauthenticated /md, /llm, or /llm/job endpoints (no prior login needed in vulnerable setups).
- Trigger point: Sending crafted requests that:
- Set a malicious or attacker-controlled base_url parameter to redirect LLM API calls.
- Use api_token values in the form env:VARIABLE_NAME to cause the server to resolve environment variables.
- Why exploitation is possible: The API endpoints implicitly trust user-controlled parameters to:
- Configure outbound LLM request targets (base_url).
- Indirectly dereference server environment variables (api_token with env: prefix).
These behaviors occur without robust authentication, authorization, or validation, leading to direct information exposure.
Why this happens
The core issue aligns with CWE-200: Information Exposure. The server logic implicitly treats user-supplied input as configuration directives for sensitive operations and secret resolution.
Specifically, the Docker API allows:
- A user-controlled base_url to influence where sensitive LLM API requests are sent, enabling redirection to attacker infrastructure.
- A user-controlled api_token with an env: prefix to cause the application to read environment variables and use them in requests.
This creates a design-level flaw where internal secrets and configuration (e.g., JWT SECRET_KEY, API keys) are directly exposed through public-facing API parameters.
The bug class can be generalized as:
- Mixing untrusted input with secret management mechanisms.
- Allowing runtime configuration and secret lookups to be driven by unauthenticated, unvalidated external data.
Potential impact
- Exfiltration of LLM provider API keys and other confidential access tokens.
- Exposure of JWT SECRET_KEY, enabling attackers to forge valid tokens and bypass authentication.
- Redirection of LLM traffic to attacker-controlled endpoints for data theft, logging of prompts, or response manipulation.
- Unauthorized access to additional environment variables containing database credentials or other infrastructure secrets.
- Escalation from a single exposed API server to broader application or account compromise via stolen credentials.
General mitigation guidance
Effective mitigations focus on hardening trust boundaries, limiting secret resolution, and enforcing strict API controls:
- Require strong authentication and authorization for all management or LLM-triggering endpoints, especially /md, /llm, and /llm/job.
- Avoid treating user-controlled parameters as direct configuration channels for secret resolution; disallow patterns like env:VARIABLE_NAME in client-facing inputs.
- Constrain configurable URLs:
- Validate base_url against a strict allowlist of trusted domains or internal services.
- Reject arbitrary or external URLs when routing LLM calls.
- Separate secret management from request-layer parameters:
- Resolve API keys and JWT secrets from fixed, server-side configuration instead of per-request hints.
- Reduce blast radius by practicing least privilege:
- Limit which secrets are present in environment variables.
- Use dedicated, minimally scoped keys for LLM and supporting services.
- Apply network-based protections:
- Restrict Docker API server exposure to internal, trusted networks or a dedicated gateway with access controls.
How teams detect issues like this
Detection should combine code-level analysis with runtime monitoring:
- Static analysis and code review:
- Flag code paths where environment variables are read based on user-controlled input (e.g., parsing env: prefixes).
- Identify endpoints that allow user-specified URLs or hosts to influence outbound connections without strong validation.
- Review authentication and authorization usage on all management and LLM-related endpoints.
- Configuration and policy checks:
- Enforce policies that forbid public exposure of internal Docker or admin APIs.
- Require allowlists for outbound destinations in services that call LLM providers.
- Runtime and log-based monitoring:
- Monitor API logs for unusual base_url values or frequent requests using api_token patterns such as env:*.
- Alert on outbound requests to unexpected or untrusted domains initiated by the LLM integration.
- Automated security tools (SAST/DAST) can help highlight information exposure patterns and misconfigurations in API routing and secret handling.

