crawl4ai icon indicating copy to clipboard operation
crawl4ai copied to clipboard

[Bug]: lxml~=5.3 is too old, can't install crawl4ai & scrapling at the same time

Open olokshyn opened this issue 5 months ago • 4 comments

crawl4ai version

0.8.9

Expected Behavior

Update the lxml dependency to allow versions >=6.0. This will allow crawl4ai to be used with other lxml-dependent packages like scrapling.

Current Behavior

crawl4ai depends on an old version of the lxml >=5.3,<6.0. This means crawl4ai cannot be installed along any other dependencies that use lxml>=6.0

One example of that is Scrapling, which is excellent at bypassing Cloudflare bot checks.

Installation with poetry fails due to incompatible lxml dependencies:

$ poetry init
...
$ poetry add scrapling
...
$ poetry add crawl4ai
Using version ^0.8.9 for crawl4ai

Updating dependencies
Resolving dependencies... (2.2s)

Because no versions of crawl4ai match >0.8.9,<0.9.0
 and crawl4ai (0.8.9) depends on lxml (>=5.3,<6.0), crawl4ai (>=0.8.9,<0.9.0) requires lxml (>=5.3,<6.0).
And because scrapling (0.4.9) depends on lxml (>=6.1.1)
 and no versions of scrapling match >0.4.9,<0.5.0, crawl4ai (>=0.8.9,<0.9.0) is incompatible with scrapling (>=0.4.9,<0.5.0).
So, because test depends on both scrapling (>=0.4.9,<0.5.0) and crawl4ai (^0.8.9), version solving failed.

Installation with pip just replaces lxml with version 5.4.0, which means breaking lxml API for all other packages in the environment.

As a side note, this old lxml dependency causes another issue on Windows: https://github.com/unclecode/crawl4ai/issues/1903

Is this reproducible?

Yes

Inputs Causing the Bug


Steps to Reproduce

See the Current behavior

Code snippets


OS

Any. It's a dependency configuration issue.

Python version

Python 3.13.13. All versions are affected.

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

No response

olokshyn avatar Jun 17 '26 13:06 olokshyn

Hi, I'd like to work on this. I'll submit a PR shortly.

nightcityblade avatar Jun 18 '26 15:06 nightcityblade

The fix is in the develop branch. will be in the next release soon

ntohidi avatar Jul 07 '26 15:07 ntohidi

Adding a security data point to the compatibility argument: lxml < 6.1.0 carries a high-severity XXE advisory (CVE-2026-41066 / GHSA-vfmq-68hx-4jfw — default iterparse()/ETCompatXMLParser() configuration allows local file reads from untrusted XML), fixed in 6.1.0. Because crawl4ai pins lxml~=5.3, downstream projects cannot remediate — the resolver proves lxml>=6.1.0 unsatisfiable with crawl4ai 0.9.0 — which matters most for exactly crawl4ai's use case, parsing hostile pages. #1903 already reports lxml 6.0.2 working in practice. Would a PR relaxing the pin to lxml>=5.3,<7 be accepted?

FirstCastSolutions423 avatar Jul 08 '26 03:07 FirstCastSolutions423

The constraint has already been relaxed to lxml>=5.3,<7 on develop (commit 057b45b). This allows projects that need lxml 6.1.0+ for the CVE fix to co-install with crawl4ai.

Crawl4ai itself doesn't use the affected APIs (iterparse() / ETCompatXMLParser()), so the vulnerability doesn't directly apply here. Raising the lower bound to >=6.1.0 would break users on systems where lxml 6 doesn't have prebuilt wheels, so the current constraint keeps it optional.

ntohidi avatar Jul 08 '26 08:07 ntohidi