Summary
Crawl4AI deployments using the Docker API before version 0.8.0 expose several HTTP endpoints that accept file:// URLs, enabling local file inclusion.
Unauthenticated remote attackers can leverage these endpoints to read arbitrary files from the server filesystem, potentially accessing sensitive configuration data, credentials, and environment variables.
Affected context
This vulnerability affects Crawl4AI instances deployed via the Docker API where the following endpoints are exposed over the network:
- /execute_js
- /screenshot
- /html
The issue arises when these endpoints accept and process file:// URLs without sufficient validation, allowing access to files on the container or host filesystem. It is most relevant when the service is reachable from untrusted networks and runs with access to sensitive system or application files.
Exploit preconditions
- Attack surface: HTTP API of the Crawl4AI Docker deployment
- Required access: None; exploitable by unauthenticated remote users if the API is publicly reachable
- Trigger point: Supplying a file:// URL to the /execute_js, /screenshot, /pdf, or /html endpoints
- Why exploitation is possible: The application treats file:// URLs as valid sources and reads from the local filesystem without restricting path targets or protocol schemes, enabling directory traversal and arbitrary file inclusion within the process context.
Why this happens
The core issue is improper handling of file:// URLs as input sources in endpoints that are intended to work with external web resources or user-provided content.
Instead of constraining acceptable URL schemes or enforcing allowlists, the implementation permits direct access to the local filesystem, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Abstractly, this reflects a broader pattern where user-controlled paths or URLs are interpreted by file-handling components without normalization, scheme validation, or confinement to a safe directory, allowing attackers to read arbitrary files that the application runtime can access.
Potential impact
- Reading system files such as /etc/passwd and /etc/shadow
- Extracting environment variables via /proc/self/environ, which may disclose API keys and secrets
- Accessing application configuration files that contain database credentials, tokens, or internal endpoints
- Gathering detailed information about the internal application structure and file layout
- Facilitating further attacks such as lateral movement, credential stuffing, or targeted exploitation based on discovered secrets
General mitigation guidance
Effective mitigation focuses on constraining how paths and URLs are interpreted and reducing the sensitivity of data accessible to the service:
- Restrict accepted URL schemes to safe types (e.g., http/https) and reject file:// and other local-resource schemes by default.
- Normalize and validate any file paths or URLs against a strict allowlist or a confined directory (chroot/jail-like behavior) when local resources are legitimately needed.
- Apply least-privilege principles to the service runtime: run under a dedicated user with minimal filesystem access, and avoid mounting sensitive host directories into containers.
- Externalize secrets to dedicated secret management solutions and avoid storing credentials or keys in world-readable files or general environment variables where possible.
- Place the API behind authentication and network controls (reverse proxies, firewalls, or service meshes) so that only trusted clients can access sensitive endpoints.
How teams detect issues like this
Several complementary strategies can help detect this vulnerability and similar patterns:
- Static analysis: Scan for code paths that:
- Accept user-controlled URLs or file paths
- Pass them directly into file I/O functions, URL loaders, or rendering engines
- Accept file:// without explicit validation or filtering
- Code review signals:
- Endpoints that generate screenshots, PDFs, HTML, or execute scripts based on user-supplied URLs
- Lack of checks on URL schemes, hostnames, or path prefixes
- Direct usage of low-level filesystem APIs in request handlers without sanitization
- Dynamic and runtime testing:
- Include security tests that send file:// URIs and known-sensitive paths (e.g., /etc/passwd, /proc/self/environ) to exposed endpoints and verify behavior.
- Use DAST or API fuzzing tools configured to probe for local file inclusion and path traversal.
- Policy enforcement:
- CI/CD policies that flag endpoints exposing raw URL-driven functionality without explicit validation layers.
- Infrastructure policies ensuring that internet-exposed services are authenticated and run with constrained filesystem access.

