Skip to content
RCE Write-up Advanced

Debugging by default

Scrapy versions before 1.5.2 enabled a telnet console without authentication, allowing local users to execute arbitrary Python commands. A malicious website could redirect a spider's request to the local telnet service and inject a crafted HTTP method to achieve remote code execution.

medium.com

Published on medium.com

This year the focus of our research will be security in web scraping frameworks. Why?

Claudio Salazar, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The telnet console was enabled by default without authentication, and Scrapy did not validate form methods or filter redirects to disallowed domains, allowing crafted requests to reach the console.

Impact

An attacker could execute arbitrary commands on the machine running the spider, leading to remote code execution, though the telnet console is only accessible locally and the attack requires a spider to visit a malicious site.

What the attacker needed

Scrapy < 1.5.2; spider visits a malicious website; telnet console enabled (default)

The fix

Scrapy 1.5.2 added authentication to the telnet console, using a random secure password if none is set.

How it was found

  1. The attacker sets up a malicious website that redirects requests to localhost:6023.
  2. The spider sends a GET request to the malicious site.
  3. The malicious site responds with a 307 redirect to the telnet service, preserving the request method.
  4. The spider follows the redirect and sends a crafted HTTP request to the telnet console.
  5. The telnet console interprets part of the request as Python code and executes it.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Scrapy is a tool for automatically downloading web pages. It included a debugging feature that let anyone on the same computer run commands as the user running Scrapy. A malicious website could trick Scrapy into sending a special request to that debugging feature, letting the attacker run commands remotely.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.