The life of an attack

This page follows one attack from start to finish. Meet Mallory, who is not a customer, and a small photo app with a line of code that trusts its input a little too much.

@app.route("/resize")
def resize():
    os.system("convert " + request.args["name"])

A request from the network is marked untrusted, followed through string building and caught at os.system; Report logs it, Raise also blocks it, and a Critical event appears.

Four stops

  1. The request. Mallory asks for a file called cat.png; rm -rf ~. It arrives over the network.
  2. Marked. es-python tags that text as untrusted the moment your app reads it.
  3. Followed. The tag stays on as your code glues the text into a command.
  4. Risky action. os.system is about to run text that came from a stranger. This is the moment EyalSec acts.

The event lands on your Events page within seconds, graded Critical, with the exact line of your code.

Two endings

Side by side: in Report mode the command runs and an event is recorded; in Report and Raise mode the program gets a RuntimeError at that line and an event is recorded.

With Report, you learn about it. With Report and Raise, Mallory's command never runs: your code gets an error at that line instead. You pick per machine and per kind of event; see Report and Raise.

Next: What es-python watches.

Something unclear or missing on this page? Email support@eyalsec.com.

EyalSec Pricing Docs Security Research Vulnerabilities Play Security glossary About Contact עברית Login Get started Protect my Python app