Skip to content

[security] RobotsParser.can_fetch() disables TLS verification (ssl=False) when fetching robots.txt #2252

Description

@liuchunyi-buaa

Description

In crawl4ai/utils.py (line 344), RobotsParser.can_fetch() issues the robots.txt request with ssl=False:

session.get(robots_url, timeout=2, ssl=False)

Certificate validation is disabled, so an on-path attacker (MITM, rogue DNS, malicious proxy) can impersonate the target host and feed arbitrary robots.txt content, silently controlling whether the crawler honors Disallow rules for the target site.

Impact is limited (robots.txt is an advisory protocol and the request carries no credentials), so I'm filing this as a hardening issue rather than a private security report.

Suggested fix

Keep TLS verification enabled for https:// URLs; allow opt-in disabling only for explicitly configured hosts:

ssl = parsed.scheme.lower() != "https"  # or an explicit per-request override

Reproduction

  1. Route the target host through a proxy that presents a self-signed certificate.
  2. Observe the robots.txt request succeeding despite the invalid certificate, and the tampered Disallow rules taking effect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions