Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-91940-crawl4ai-Arbitrary-File-Write — CVE-2026-91940: arbitrary file write in crawl4ai <=0.9.2 via the untrusted-config gate (PDFContentScrapingStrategy image_save_dir). Analysis, reproduction harness and verified 0.9.2 vs 0.9.3 boundary. | Kitploit
Tools/GitHubGitHub/biitts/cve-2026-91940-crawl4ai-arbitrary-file-write
Vulnerability AnalysisExploitationWeb Application ExploitationPapers & ResearchLabs & Practice
GitHubbiitts/cve-2026-91940-crawl4ai-arbitrary-file-write

CVE-2026-91940-crawl4ai-Arbitrary-File-Write

CVE-2026-91940: arbitrary file write in crawl4ai <=0.9.2 via the untrusted-config gate (PDFContentScrapingStrategy image_save_dir). Analysis, reproduction harness and verified 0.9.2 vs 0.9.3 boundary.

View Repository
21 month agoNot yet reviewed
Share

CVE-2026-91940: arbitrary file write in crawl4ai through the untrusted-config gate

CVECVE-2026-91940
Productcrawl4ai, ~84k stars
Affected>= 0.9.0, <= 0.9.2
Fixed0.9.3
ClassCWE-22, arbitrary file write (attacker-chosen directory, byte-exact content)
Privilegesa caller able to reach POST /crawl. See Privileges
VerdictCONFIRMED VULNERABLE on 0.9.2, PATCHED on 0.9.3, both reproduced end to end
CVSS 3.16.5 AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N (NVD publishes 7.5 with PR:N, which does not hold for 0.9.2)
AdvisoryGHSA-xpp7-j28w-2gvx

Table of contents

  • What the bug is
  • Root cause, line by line
  • Why the written content is byte-exact
  • Privileges, and why this is not unauthenticated on 0.9.2
  • Two more corrections to the public record
  • Impact, bounded honestly
  • Reproducing it
  • What the evidence actually proves
  • Remediation
  • Detection
  • Credits

What the bug is

crawl4ai's HTTP API accepts a configuration object inside the request body. Because a body is attacker-controlled, the project built a trust boundary for it: configs loaded with Provenance.UNTRUSTED are passed through a gate that is supposed to drop or reject any field that an untrusted caller must not set.

That gate fails open for one reachable class. PDFContentScrapingStrategy is explicitly constructible from an untrusted body, but it has no field allowlist, and the gate's rule for "no allowlist" is "keep everything". So its image_save_dir reaches the PDF processor untouched, and the processor creates that directory and writes the images of the fetched PDF into it with no containment check. The result is a write to any directory the service account can reach, with content the caller supplies.

Root cause, line by line

1. The endpoint marks the body untrusted (deploy/docker/server.py):

crawler_config = CrawlerRunConfig.load(
    crawl_request.crawler_config, provenance=Provenance.UNTRUSTED
)

2. The gate keeps every field of a type that has no allowlist (crawl4ai/async_configs.py):

def _filter_untrusted_fields(type_name: str, params: dict) -> dict:
    """Drop non-allowlisted fields and raise on forbidden (power) fields."""
    forbidden = UNTRUSTED_FORBIDDEN_FIELDS.get(type_name, set())
    allowlist = UNTRUSTED_FIELD_ALLOWLIST.get(type_name)  # None => keep all non-forbidden
    out = {}
    for key, value in params.items():
        if key in forbidden:
            raise UntrustedConfigError(...)
        if allowlist is not None and key not in allowlist:
            continue  # silently drop unknown/unsafe fields (forward-compatible)
        out[key] = value
    return out

3. The PDF strategy is reachable but has neither an allowlist nor a forbidden list. UNTRUSTED_ALLOWED_TYPES contains PDFContentScrapingStrategy, so a body can build one through CrawlerRunConfig.scraping_strategy. But UNTRUSTED_FIELD_ALLOWLIST has keys only for BrowserConfig and CrawlerRunConfig, and UNTRUSTED_FORBIDDEN_FIELDS likewise. So allowlist is None, forbidden is empty, and extract_images, save_images_locally and image_save_dir all survive.

4. The sink trusts that path (crawl4ai/processors/pdf/processor.py):

if self.extract_images and self.save_images_locally:
    if self.image_save_dir:
        image_dir = Path(self.image_save_dir)
        image_dir.mkdir(exist_ok=True, parents=True)

Absolute path accepted, directories created recursively, no realpath containment check against a storage root. _extract_images() then writes each image of the PDF there.

5. The PDF is fetched by the strategy itself. PDFContentScrapingStrategy.scrap() calls self._get_pdf_path(url), which downloads the URL independently of the crawler's browser stage. So the bytes that get written come from a file the attacker hosts.

Why the written content is byte-exact

This part is absent from the advisory, which only says "attacker-controlled bytes" without saying how. Only the /FlateDecode branch of _extract_images() goes through PIL (img.save(final_path)) and is therefore re-encoded to PNG. The other three branches write the raw PDF stream:

PDF /Filterwritten extensionhow it writes
/DCTDecode.jpgopen(final_path, 'wb').write(data)
/CCITTFaxDecode.tiffsame, and a TIFF header is prepended only when data[:4] != b'II*\x00'
/JPXDecode.jp2same
/FlateDecode.pngre-encoded by PIL, so not byte-exact

Embedding the payload as a /DCTDecode image XObject therefore puts those exact bytes on disk. This was confirmed by comparing checksums: the md5 of the file written on the server equals the md5 of the payload handed to exploit.py.

Privileges, and why this is not unauthenticated on 0.9.2

NVD scores this PR:N. On the 0.9.2 build that does not hold, and the difference was measured rather than assumed.

The image ships auth_gate.py, a fail-closed AuthGateMiddleware mounted at the outermost ASGI layer. Its own docstring explains why it exists:

The previous design decided auth in a per-route FastAPI dependency that, when jwt_enabled was false (the default), returned lambda: None, so every Depends(token_dep) was decorative and the whole API was open.

It now covers every route, mount and sub-app, HTTP and WebSocket, and rejects a request without a valid credential before any handler runs. On top of that, when no CRAWL4AI_API_TOKEN is set the entrypoint binds loopback only and logs an ephemeral token for that session. A request with no credential gets:

HTTP/1.1 401
{"detail": "Authentication required"}

The vulnerability is still real, and the reason matters: crawl4ai treats the request body as untrusted even when it comes from a legitimate API caller. That is the entire purpose of Provenance.UNTRUSTED. So a caller who is allowed to use the API, a tenant, a downstream service, a low-privileged user of a shared deployment, escalates to arbitrary file write on the host. That is PR:L, which is where the 6.5 comes from instead of 7.5.

Two more corrections to the public record

pypdf is not in the official image. The advisory states that it is, and that therefore no extra install is needed. In unclecode/crawl4ai:0.9.2, pip list reports only Crawl4AI 0.9.2 and pillow 12.3.0, and find / -iname 'pypdf*' returns nothing. Without it, NaivePDFProcessorStrategy.__init__ raises ImportError, so the write requires a deployment that installed the crawl4ai[pdf] extra or built a custom image.

That failure is itself useful, because it proves the gate bypass without the write even happening. The ImportError surfaces from inside the construction call:

async_configs.py:470   k: from_serializable_dict(v, provenance) for k, v in params.items()
async_configs.py:472   return cls(**constructor_args)
processors/pdf/__init__.py:63   self.pdf_processor = NaivePDFProcessorStrategy(
processors/pdf/processor.py:64  raise ImportError("pypdf is required for PDF processing...")

The untrusted image_save_dir reached the strategy constructor. It was not dropped and not rejected. The only thing standing between that and a write is a missing library.

Download Tool

Most Popular

View all →

Discover the most used tools by our community.

No popularity data yet.

Explore all tools

Browse our collection of tools

View all tools →