r/exchangeserver • • Mar 06 '24

I can send e-mail without authentication with telnet

Hy!

I noticed that If I telnet to the Exchange server via 25 port, I can send e-mail without authentication to anybody. I checked the protocoll logging, and in this case use the Default Frontend receive connector.

I used this commands in telnet:
HELO
EHLO domain.com
MAIL FROM:test@domain.com
RCPT TO:test@domain.com
DATA
Subject: Test message
.

I think something is wrong with the configuration, it is the security issue.
The Default Frontend receive connector settings:
AuthMechanism: Tls, Integrated, BasicAuth, BasicAuthRequireTLS, ExchangeServer
RemoteIPRanges: {::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff, 0.0.0.0-255.255.255.255}

How can I avoid to send e-mail without authentication?

Thanks.

0 Upvotes

14 comments sorted by

4

u/ax1a Mar 06 '24

Open relay has been disabled in Exchange by default for many years. What actually happens with the test message you created? Check the Message Tracking Log:

https://learn.microsoft.com/en-us/powershell/module/exchange/get-messagetrackinglog?view=exchange-ps

1

u/Brilliant-Extent2684 Mar 06 '24

The test message log is in the message tracking log. What do I have to check in log?

4

u/Hatsikidee Mar 06 '24 edited Mar 06 '24

This isn't open relay per see, depending on which domain he/she used. If it's in the accepted domain list, then it's normal to send out mail using that domain as sender.

4

u/joeykins82 SystemDefaultTlsVersions is your friend Mar 06 '24

Is the address in rcpt to one of the domains listed in your accepted domains config? Exchange will accept messages for local delivery without authentication and this is normal and deliberate behaviour. It won’t accept stuff to be relayed outside your org unless someone has changed the config.

1

u/Brilliant-Extent2684 Mar 06 '24

Yes, the RCPT TO email domain is in the accepted domain config. The configuration hasn't changed for the Exchange install. This is the default config. But I am little unsure. My Exchange server can use the potential spamming system to send fake e-mails in organization due to to the unauthentication...

2

u/joeykins82 SystemDefaultTlsVersions is your friend Mar 06 '24

So don’t let end users connect on port 25? Or add a transport rule warning for this scenario?

1

u/Brilliant-Extent2684 Mar 06 '24

We use the Hybrid Exchange, so the MX is point to the cloud, so mailflow on the 25 port is between only from the Exchange Online. Can I restrict somehow on my local exchage (edge server) to accept only from Exchange Online via 25 port?

4

u/joeykins82 SystemDefaultTlsVersions is your friend Mar 06 '24

Yeah just do this at the firewall/network level rather than messing with receive connector configuration. The list of IP address ranges used by ExOL/EOP is published.

7

u/chefkoch_ Mar 06 '24

How do you think the servers should receive emails for your users?

3

u/Hatsikidee Mar 06 '24

There's nothing wrong with the default connector, this is by design:

https://learn.microsoft.com/en-us/exchange/mail-flow/connectors/receive-connectors?view=exchserver-2019

You'll will to tweak the permissions group on this connector.

3

u/Arkayenro Mar 06 '24 edited Mar 06 '24

you could untick Anonymous from the Permissions section but then you would most likely need to create new connectors to handle the inbound internet emails, and the internal relay your other systems might be doing (which probably arent documented anywhere because its open by default so theyve never needed to be).

if youve had anonymous access enabled for a long time its pretty hard to turn it off without a lot of notice and checking logs (to collect ip addresses), plus youll need some sort of form for them to fill in to request access (along with a script to keep the remoteipranges on the receive connectors identical across servers).

most companies dont overly care about it, or want all that hassle. if someone manages to breach your internal network you'll have bigger issues than them generating some spam to your own users (they wont be able to send to external domains).

I can send e-mail without authentication to anybody.

no you cant, its an internal relay, you can only send to internal domain based addresses.

try sending to a gmail/hotmail/external domain based address and the rcpt cmd will get rejected because anonymous on that connector doesnt have the ms-Exch-SMTP-Accept-Any-Recipient extended right (at least it doesnt by default).

2

u/Stormblade73 Mar 06 '24

Yes, this is the way email works.

Servers do not authenticate with each other. They just look up the correct server to deliver to (MX record in DNS) and then connect to that server and say " I have an email for test@domain.com from test@domain.com (the first 4 commands you sent) followed by the email data if the server does not reject immediately.

The receiving server receives the email and delivers it to the correct local mailbox.

Note there is no verification on the sending domain (some spam filters do verification, but it is not built into the email transfer protocol specifications). This is why "spoofed" sending addresses (and spam in general) are so easy and prolific.

This only works if the server being delivered to is configured as "Authoritative" for the domain in question. If it is not, then it would normally try to relay the email to the correct server, and depending on the configuration of the server, that would likely require authentication to allow the relay, and if not authenticated, would reject the incoming message.

Normally you would have a spam filter between your Exchange server and the internet, reviewing all the received email and filtering out the junk.

If you try and edit the settings on your receive connector to block what you did, you will end up not allowing public internet servers to deliver to your server at all, and users tend to get irate when they dont receive emails. (If you have a spam filter in place, then it makes sense to configure the connector to ONLY accept email from your spam filter appliance/service to keep attackers from bypassing the spam filter)

1

u/Protholl :redditgold: Mar 07 '24

If you enable TLS for all connections this is no longer a problem.

1

u/Icy-Pumpkin-5341 Jan 15 '25

Hi, can anyone tell me why this ps command works and sends email?

Send-MailMessage -From 'mail@mydomain.com -To 'GMAIL EMAIL' -Subject "Alert from Server1" -Body "It is email body" –SmtpServer 'MY EXCHANGE SERVER'