{"id":"PYSEC-2026-319","summary":"Crawl4AI: AST Sandbox Escape via gi_frame.f_back Chain - Pre-Auth RCE in Docker API","details":"### Summary\n\nThe `_safe_eval_expression()` function in the computed fields feature uses an AST validator that only blocks attributes starting with underscore. Python generator and frame object attributes (`gi_frame`, `f_back`, `f_builtins`) do NOT start with underscore, enabling a complete sandbox escape to achieve arbitrary code execution.\n\nThe attack requires no authentication (JWT disabled by default) and is triggered via `POST /crawl` with a crafted extraction schema.\n\n### Attack Vector\n\nAn attacker sends a `POST /crawl` request with a `JsonCssExtractionStrategy` schema containing a malicious computed field expression that:\n1. Creates a generator to access `gi_frame`\n2. Walks the frame chain via `f_back`\n3. Reaches `f_builtins` containing the real `__import__`\n4. Imports `os` and executes arbitrary commands\n \n### Impact\n\nUnauthenticated remote code execution inside the Docker container. An attacker can execute arbitrary system commands, read/write files, and exfiltrate secrets.\n\n### Fix Details\n\n1. Removed `eval()` from computed field expression path entirely -- expressions now log a warning and return default value\n2. Deleted `_safe_eval_expression()` function and `_SAFE_EVAL_BUILTINS` (dead security-sensitive code)\n3. `function` key with Python callables still works for SDK users\n4. Replaced `eval()` in `/config/dump` with JSON-based input validated by Pydantic\n5. Fixed hook_manager sandbox: stripped `__builtins__`, `__loader__`, `__spec__` from injected modules; removed `getattr`, `setattr`, `type`, `__build_class__` from allowed builtins\n \n### Workarounds\n\n1. Upgrade to the patched version (recommended)\n2. Enable JWT authentication via `CRAWL4AI_API_TOKEN` environment variable\n3. Restrict network access to the Docker API\n\n### Credits\n\n- Song Binglin ([q1uf3ng](https://github.com/q1uf3ng)) - reported the AST sandbox escape\n- by111 ([August829](https://github.com/August829)) - reported the hook sandbox `__builtins__` escape and hardcoded JWT secret bypass\n - [jannahopp](https://github.com/jannahopp) - PR #1855 proposing eval removal\n - [ntohidi](https://github.com/ntohidi) - PR #1886 proposing allowlist approach","aliases":["CVE-2026-53753","GHSA-qxjp-w3pj-48m7"],"modified":"2026-06-29T12:15:17.075083240Z","published":"2026-06-29T11:50:52.380343Z","references":[{"type":"WEB","url":"https://github.com/unclecode/crawl4ai/security/advisories/GHSA-qxjp-w3pj-48m7"},{"type":"WEB","url":"https://github.com/unclecode/crawl4ai/pull/1855"},{"type":"WEB","url":"https://github.com/unclecode/crawl4ai/pull/1886"},{"type":"PACKAGE","url":"https://github.com/unclecode/crawl4ai"},{"type":"PACKAGE","url":"https://pypi.org/project/crawl4ai"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-qxjp-w3pj-48m7"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53753"}],"affected":[{"package":{"name":"crawl4ai","ecosystem":"PyPI","purl":"pkg:pypi/crawl4ai"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.8.7"}]}],"versions":["0.3.0","0.3.1","0.3.2","0.3.3","0.3.4","0.3.5","0.3.6","0.3.7","0.3.71","0.3.72","0.3.73","0.3.731","0.3.74","0.3.741","0.3.742","0.3.743","0.3.744","0.3.745","0.3.746","0.3.8","0.4.0","0.4.1","0.4.21","0.4.22","0.4.23","0.4.24","0.4.241","0.4.242","0.4.243","0.4.244","0.4.245","0.4.246","0.4.247","0.4.248","0.4.248b3","0.4.3b1","0.4.3b2","0.4.3b3","0.5.0","0.5.0.post1","0.5.0.post2","0.5.0.post3","0.5.0.post4","0.5.0.post5","0.5.0.post6","0.5.0.post7","0.5.0.post8","0.6.0","0.6.0rc1","0.6.1","0.6.2","0.6.3","0.7.0","0.7.1","0.7.2","0.7.3","0.7.4","0.7.5","0.7.6","0.7.7","0.7.8","0.8.0","0.8.5","0.8.6"],"database_specific":{"source":"https://github.com/pypa/advisory-database/blob/main/vulns/crawl4ai/PYSEC-2026-319.yaml","last_known_affected_version_range":"\u003c= 0.8.6"}}],"schema_version":"1.7.5","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}]}