Skip to content
Misconfiguration Disclosed report Intermediate

Mailgun misconfiguration leads to email snooping and postmaster@-access on email.mg.gitlab.com

A Mailgun configuration issue allowed an attacker to claim the domain email.mg.gitlab.com because it was not added as a separate domain in Mailgun, and a CNAME record pointed to Mailgun. The attacker could then create a mailing list for [redacted] and receive emails sent to that address.

Frans Rosén Follow

Originally disclosed on HackerOne

  • Fixed in under an hour
  • Disclosed after 56 days

Summary by the program

@fransrosen Identified a vulnerability in our Mailgun configuration that allowed mail to several of our subdomains to be leaked. @fransrosen included enough information in the report so that we were able to immediately correct the issue and report the problem to Mailgun. Thanks @fransrosen for one of the more interesting vulnerability reports we've seen!

The report

Hi,

Previously a blog post went out about Uber's Sendgrid issues: http://blog.pentestnepal.tech/post/149985438982/reading-ubers-internal-emails-uber-bug-bounty

Also, a report from @uranium238 went out due to a similar issue with Slack (that I know uses Mailgun): https://hackerone.com/reports/163938

Now, by reasons I do not know, this actually has some issues still unpatched by Mailgun, which in combination with a misconfiguration, currently exposes at least email.mg.gitlab.com.

The problem lies in this issue:

  1. You add the domain mg.gitlab.com to Mailgun
  2. Mailgun asks you to add a MX record to mg.gitlab.com
  3. You add that, then Mailgun also tells you that to get tracking you need to add a CNAME from email.mg.gitlab.com to mailgun.org as well.
  4. What is missing here, is for you to actually add email.mg.gitlab.com to your account as a separate domain by itself. By not doing this, anyone can add this domain to their account.
  5. You probably later on remove the MX from mg.gitlab.com again, but the CNAME is still there for email.mg.gitlab.com

The problem with missing out on #4 above is how DNS CNAMEs works. If you have a CNAME pointing to another domain, this CNAME will actually inherit the MX-records from the other domain. This basically means that your email.mg.gitlab.com is now listed with MX-records from Mailgun:

$ host email.mg.gitlab.com
email.mg.gitlab.com is an alias for mailgun.org.
mailgun.org has address 173.203.37.113
mailgun.org mail is handled by 10 mxb.mailgun.org.
mailgun.org mail is handled by 10 mxa.mailgun.org.

Due to this, I can claim this domain as mine in Mailgun:

Screen_Shot_2016-10-10_at_20.13.53.png
Screen_Shot_2016-10-10_at_20.13.53.png From the original on HackerOne

And due to this, I can now create a mailing list called [email protected] with Access-level: everyone:

Screen_Shot_2016-10-10_at_20.14.05.png
Screen_Shot_2016-10-10_at_20.14.05.png From the original on HackerOne

I'll add my own email as a recipient:

Screen_Shot_2016-10-10_at_20.14.10.png
Screen_Shot_2016-10-10_at_20.14.10.png From the original on HackerOne

I'll now try and see if I can receive emails to [email protected]:

Screen_Shot_2016-10-10_at_20.14.38.png
Screen_Shot_2016-10-10_at_20.14.38.png From the original on HackerOne

The logs of Mailgun will show me the routing:

Screen_Shot_2016-10-10_at_20.15.05.png
Screen_Shot_2016-10-10_at_20.15.05.png From the original on HackerOne

And my inbox now have the emails sent to [email protected]:

Screen_Shot_2016-10-10_at_20.15.13.png
Screen_Shot_2016-10-10_at_20.15.13.png From the original on HackerOne

Since postmaster can be used to issue certificates for these domains, and since no one but you should have access to the whitelisted SSL-issuing aliases (ref: https://wiki.mozilla.org/CA:Problematic_Practices#Email_Address_Prefixes_for_DV_Certs)
I recommend that you:

  1. Add the both domains email.mg.gitlab.com to your Mailgun account. I have removed it again so you can take it back, remember that anyone can right now claim it themselves..
  2. Keep in mind that all domains pointing to Mailgun (MX/CNAME) needs to be claimed by you, even the sub sub domains of the ones already in Mailgun. So make sure that no other domains pointing to Mailgun are missing inside your Mailgun account.

Regards, Frans

The original report as published on HackerOne, by fransrosen. 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

The domain email.mg.gitlab.com was not added as a separate domain in Mailgun, and because a CNAME pointed to Mailgun, it inherited Mailgun's MX records, allowing anyone to claim it.

Impact

An attacker could receive emails sent to [redacted], and postmaster can be used to issue certificates for the domain.

What the attacker needed

Mailgun account; domain not claimed in Mailgun

The fix

The domain email.mg.gitlab.com should be added to the Mailgun account, and all domains pointing to Mailgun via MX or CNAME should be claimed.

How it was found

  1. Add the domain mg.gitlab.com to Mailgun and set up the required MX record.
  2. Add a CNAME record from email.mg.gitlab.com to mailgun.org for tracking.
  3. Do not add email.mg.gitlab.com as a separate domain in Mailgun.
  4. An attacker can then claim email.mg.gitlab.com in their own Mailgun account.
  5. The attacker creates a mailing list for [redacted] with access level 'everyone'.
  6. The attacker adds their own email as a recipient and receives emails sent to [redacted]

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.

Mailgun is an email service. When you set up a domain with Mailgun, you add DNS records so Mailgun can send and receive email for you. If you forget to add a subdomain like email.mg.gitlab.com to your Mailgun account, someone else can add it to their own account and start receiving emails sent to that subdomain.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by Frans Rosén

View all

26 more disclosed reports, best first.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.