Skip to content
RCE Write-up Advanced

CVE-2023-33733 reportlab RCE

A sandbox bypass in the Reportlab Python library allowed an attacker to execute arbitrary code by crafting a malicious HTML colour attribute that evaded the safe evaluation environment. This could lead to remote code execution when Reportlab processes untrusted HTML input.

c53elyas Follow

Published on github.com

BranchesTags

c53elyas, on github.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 sandbox's custom getattr and type functions could be bypassed by creating a subclass of str that manipulates equality checks and by calling type on itself to retrieve the original builtin type, allowing access to dangerous attributes like __globals__.

Impact

An attacker could execute arbitrary code on the server if the application processes malicious HTML with Reportlab, potentially leading to full system compromise.

What the attacker needed

Application uses Reportlab to process untrusted HTML; attacker can supply HTML input

The fix

The vulnerability was fixed in Reportlab version 3.6.13 and later, which properly restricts the sandbox.

How it was found

  1. Craft an HTML file with a font colour attribute containing a malicious Python expression.
  2. Use xhtml2pdf to convert the HTML to PDF, triggering the vulnerable eval.
  3. The exploit executes a system command, creating a file in /tmp.

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.

Reportlab is a tool that turns HTML into PDF files. It tried to run small bits of Python code safely, but a flaw let attackers sneak in harmful commands. This means if a website used Reportlab to make PDFs from user input, an attacker could run their own code on the server.

What is RCE?

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

More from ReportLab

View all

The newest disclosed reports for this program.

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.