Skip to content

docs: Add guide secure-scraping#1908

Open
Mantisus wants to merge 2 commits into
apify:masterfrom
Mantisus:secure-scraping
Open

docs: Add guide secure-scraping#1908
Mantisus wants to merge 2 commits into
apify:masterfrom
Mantisus:secure-scraping

Conversation

@Mantisus
Copy link
Copy Markdown
Collaborator

@Mantisus Mantisus commented May 22, 2026

Description

  • Add a guide covering the security threats a crawler can encounter while scraping, how to handle each of them, and the Crawlee defaults that already mitigate some of them.

Issues

@Mantisus Mantisus marked this pull request as ready for review May 24, 2026 17:02
@Mantisus Mantisus assigned janbuchar, vdusek and Mantisus and unassigned janbuchar and vdusek May 24, 2026
@Mantisus Mantisus requested review from janbuchar and vdusek May 24, 2026 17:03
Copy link
Copy Markdown
Collaborator

@vdusek vdusek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few thoughts

Because the target decides what your crawler receives, a malicious or compromised site can try to:

- **Steer your crawler to URLs you never intended to visit** - other hosts, or internal services that are not reachable from the public internet.
- **Reach non-HTTP destinations** through schemes like `file://`, `gopher://`, `ftp://`, or `dict://`, to read local files or talk to services such as Redis.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems weird to me to specify just Redis and nothing else without any further context 🙂


- **Steer your crawler to URLs you never intended to visit** - other hosts, or internal services that are not reachable from the public internet.
- **Reach non-HTTP destinations** through schemes like `file://`, `gopher://`, `ftp://`, or `dict://`, to read local files or talk to services such as Redis.
- **Exhaust your resources** with a crawler trap, an oversized response, or a decompression bomb.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should either explain the individual "traps" or provide external links


:::info

Crawlee for Python had this SSRF gap in its sitemap and `robots.txt` handling before version 1.7.0, fixed in [#1862](https://github.com/apify/crawlee-python/pull/1862) and [#1864](https://github.com/apify/crawlee-python/pull/1864). See the advisory [GHSA-3r75-xc34-5f44](https://github.com/apify/crawlee-python/security/advisories/GHSA-3r75-xc34-5f44).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we wanna mention this - @B4nan, could you tell us your opinion please?


When following links from a page, <ApiLink to="class/EnqueueLinksFunction">`enqueue_links`</ApiLink> keeps only those on the same hostname by default and filters out links to any other host. Crawlee also re-checks the host a request finally lands on, so a redirect that ends on a different host is rejected. The client still walks the whole chain to get there, though, so an intermediate hop to an internal address is fetched along the way. Note that `same-hostname` does **not** include subdomains - `example.com` will not match `api.example.com`.

```python
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it is a small code example, but for maintainability, could you please implement it as a dedicated Python script, as we do for others? (applies to all examples)


Isolation also changes the calculus for the application-level controls: inside a dedicated, egress-restricted environment the blast radius of an SSRF is contained, so widening the scope with `strategy='all'` or accepting arbitrary URLs is far less risky than it would be on a shared host.

## Running on the Apify platform
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this could be a subsection of isolation? 🙂

@@ -0,0 +1,123 @@
---
id: secure-scraping
title: Secure scraping
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "Security of web scraping" would be better?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secure scraping guide

4 participants