Skip to content
RCE Write-up Intermediate

Latex to RCE private bug bounty program

The LaTeX-to-PDF conversion feature allowed injection of LaTeX commands that could read local files and execute commands on the server. The attacker used this to achieve remote code execution and later accessed the database and Elasticsearch via SSRF.

Yashar Shahinzadeh Follow

Published on medium.com

{{media:0}}

Yasho, 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

Likely the LaTeX conversion process allowed arbitrary LaTeX commands, including those that can read files or execute shell commands, without sandboxing or input sanitisation.

Impact

An attacker with editor privileges could execute arbitrary commands on the server, leading to full compromise, and could use SSRF to access internal services such as the database and Elasticsearch.

What the attacker needed

Editor account (obtained via XSS)

How it was found

  1. Obtain an editor account (via a separate XSS, not detailed here).
  2. Access the LaTeX to PDF conversion feature.
  3. Submit LaTeX code designed to read local files.
  4. Observe the contents of /etc/passwd in the output.
  5. Submit LaTeX code designed to execute commands.
  6. Observe command output, then automate the process with a Python server to receive results out-of-band.

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.

LaTeX is a typesetting system often used for scientific documents. If a website lets users submit LaTeX code and then converts it to PDF without proper restrictions, an attacker can include special LaTeX commands that make the converter read files or run programs on the server. This is dangerous because it can lead to full control of 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 by Yashar Shahinzadeh

View all

6 more disclosed reports, best first.

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.