Skip to content
Memory corruption Write-up Advanced

From theory to practice: analysis and PoC development for CVE-2020-28018 (Use-After-Free in Exim)

A use-after-free in Exim's TLS write path allows a remote attacker to leak heap pointers, read arbitrary memory, and write arbitrary data, ultimately leading to remote code execution. The vulnerability is triggered by sending a partial SMTP command over TLS, closing the TLS session, and then re-entering TLS to use the freed buffer.

adepts.of0x.cc

Published on adepts.of0x.cc

Dear Fellowlship, today’s homily is about building a PoC for one of the vulnerabilities published by Qualys in Exim. Please, take a seat and listen to the story.

The author, on adepts.of0x.cc

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

Impact

A remote attacker could leak heap pointers, read arbitrary memory, write arbitrary data, and ultimately execute code on the server, but only if TLS with OpenSSL is enabled and X_PIPE_CONNECT is disabled.

What the attacker needed

TLS enabled with OpenSSL; X_PIPE_CONNECT disabled; Vulnerable Exim version

How it was found

  1. Connect to the server and send EHLO and STARTTLS to start a TLS session.
  2. Send a MAIL TO or RCPT TO command pipelined with a partial NOOP command (e.g., 'NO') and then close the TLS session to return to plaintext.
  3. Send the rest of the NOOP command (e.g., 'OP\n') to complete it.
  4. Send an EHLO command to trigger smtp_reset(), which frees the buffer that `corked` points to.
  5. Send STARTTLS again to start a new TLS session and then send any command to trigger tls_write(), which uses the freed `corked` pointer.

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.

This report describes a use-after-free bug in Exim, a mail server. A use-after-free happens when a program keeps a pointer to memory after it has been freed, and later uses it again. An attacker can exploit this to read or write memory they shouldn't, and eventually run their own commands on the server.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.