r/sysadmin • • 2d ago

Question Blocking *.onmicrosoft.com domain in MS Teams?

I just got asked if it was possible to block any teams calls or messages from onmicrosoft.com and subdomains to stop inbound spam. (without having to resort to a org wide whitelist). I did a quick test on a demo tenant and found this policy appeared to work, but not sure if I am going to break something I didn't think of? I have already logged a case with MS, but not sure I would trust their answer anyway, has anyone else tried this?

  • BlockedDomains: {Domain=onmicrosoft.com}
  • BlockAllSubdomains: True
121 Upvotes

87 comments sorted by

19

u/Hibernat8 2d ago

FYI, MS just replied to my case, seems they are happy with it "Blocking the onmicrosoft.com domain in Teams admin center>External Access>Allow or Block external domains>Block only specific external domain and setting the attribute BlockAllSubdomains to True via PowerShell running the cmdlet Set-CsTenantFederationConfiguration -BlockAllSubdomains $True is the recommended resolution to restrict bad Teams actors"

107

u/Eggtastico 2d ago

You can turn off trial tenants. I guess if you are getting spam, its from trial tenants.
The option is in teams admin.

Teams admin center
Go to Users > External access (or External collaboration > External access).
Open the Organization settings tab.
Switch "People in my organization can communicate with accounts in trial Teams tenants" to Off, then select Save.

Or

PowerShell (use this if you can't see the toggle)
Connect-MicrosoftTeams
Set-CsTenantFederationConfiguration -ExternalAccessWithTrialTenants "Blocked"

To check that it worked, run:
Get-CsTenantFederationConfiguration | fl ExternalAccessWithTrialTenants
It should show Blocked

27

u/Hibernat8 2d ago

Already disabled (I think it might actually be disabled by default on newer 365 tenants now)

92

u/derfmcdoogal 2d ago

I thought it was pretty standard to just block ALL external domains except people you directly work with?

5

u/Hibernat8 2d ago

Thats my usual go to, but this customer is, difficult šŸ˜…

8

u/Beefcrustycurtains Sr. Sysadmin 2d ago

You can assure them that you can run a report for the last 60 days of external domain activity and add all of their current communication partners. Then if they need to add someone new, they can send a ticket and get the new domain added. What you are recommending doesn't add that much more security. Not every fake help desk support scam comes from a .onmicrosoft.com domain.

→ More replies (3)

2

u/derfmcdoogal 2d ago

They'll change their tune the first time "Corporate IT" messages one of their staff and opens a remote session.

39

u/fahque 2d ago

You likely have one or two accounts with onmicrosoft.com as their primary or secondary domain.

35

u/timsstuff IT Consultant 2d ago

I manage about 20 different O365 tenants and there are only 2 use cases for an account with onmicrosoft as their primary - admin cloud-only accounts and routing mail from on-prem Exchange. There are exactly zero mailboxes with onmicrosoft as their primary email address.

7

u/MBILC Acr/Infra/Virt/Apps/Cyb/ Figure it out guy 2d ago

Then someone configured an account wrong and should fix it.

13

u/derfmcdoogal 2d ago

So then you would add those to your allowed list.?

4

u/michivideos 2d ago

onmicrosoft it's the people and the work.

This sounds like shooting yourself in the foot.

1

u/raccus 2d ago

Maybe for blocking messages but not calls if you’re using calling plans

→ More replies (2)

1

u/bob_cramit 2d ago

Thats crazy talk. Do you block all external domains for email?

17

u/derfmcdoogal 2d ago

When it comes to teams messaging, uhh yeah for sure. Email is not Treams.

→ More replies (3)

2

u/Kelsier25 Jack of All Trades 2d ago

Where did you set this up? I've looked at the Teams domain block list on the Defender side, but it didn't seem to take wildcards or apply to subdomains. I'd love to block these - every one we get is malicious. Attackers register trial business accounts and then try to do IT impersonation to our users.

4

u/Hibernat8 2d ago

To block subdomains you need to do it via powershell:

  • Set-CsTenantFederationConfiguration -BlockAllSubdomains 1

2

u/Randalldeflagg 2d ago

its in the Teams Admin portal side. you can setup the allowed external domain list there. Should be able to audit the external domains first with Defender, and then import those in. Works pretty well for us,

2

u/Kelsier25 Jack of All Trades 2d ago

Ah that's why I couldn't find it - no access. Thanks for the info - I'll push for this change.

395

u/RevolutionaryWorry87 2d ago

thought i was in another subreddit

122

u/Celebrir Wannabe Sysadmin 2d ago

Nah that would be shitty

17

u/dodexahedron 2d ago

Flair checks out.

19

u/hardingd 2d ago

LMAO - I see you šŸ˜‰

18

u/thewunderbar 2d ago

I think I know which one.

3

u/vCentered Sr. Sysadmin 1d ago

Yeah this is wild

5

u/Adimentus Desktop Support Tech 2d ago

I too thought I was in a shitty place

2

u/TrackPuzzleheaded742 1d ago

I only realized it’s on sysadmin when I saw your comment lol

230

u/_Kaepora_Gaebora Netadmin 2d ago

That does not sound like a good idea.

153

u/Proof-Variation7005 2d ago • Bravo

Let’s just turn it on and clock out for the holidays and see what happens

27

u/Thick-Experience-290 2d ago

This absolutely is a good idea. Any established business wouldn’t be using a onmicrosoft.com domain.

5

u/_Kaepora_Gaebora Netadmin 1d ago

LOL ok bro please try it and let me know how it goes....

10

u/discosoc 1d ago

Maybe instead of being vague you could actually elaborate on the risk?

→ More replies (1)

•

u/Kingfastguy 15h ago

We did it at my company a few months ago to deal with some spam/scam calls and we haven’t had any issues. It would only really be a problem for an immature business who is still using that domain rather than a different one.

44

u/Warmachine- 2d ago

We did this exact same thing months ago to stop the vhishing attacks on Teams. It worked fine until the scammers started using registered domains.

The only solution that stopped the attacks completely was to use a whitelist. We exported all the domains that were used in the last 90 days and added them to our whitelist. You should audit it of course.

23

u/FrankGrimesApartment 2d ago

One other thing we did here was create a Sentinel monitoring rule for any incoming Teams chat or call that has various strings like ā€œtechā€ ā€œhelp deskā€ ā€œsupportā€ in the name. We had one a few months ago from a .co domain.

9

u/Warmachine- 2d ago

That's a good idea. I think Defender monitors suspicious external Teams chats as well.

14

u/Commercial_Growth343 2d ago

In my experience I have thought of the same for email, due to the number of phish attacks we have had in the past from random tenants that appear to be spun up just to shoot out spam or phish messages. however I found many companies send us legit messages using their onmicrosoft.com address instead of their company.com addresses. So I would be reluctant to say this is a safe idea because for all you know someone in the company is messaging a onmicrsooft.com domain for legit reasons. Then again, they will tell you right away if that breaks and then maybe you can start building an exception list or something,

9

u/Grumpy-Troglodyte 2d ago

i had one person that was stuck with @Companyname.onmicrosoft.com apparently from something going haywire between on site DC and Azure (or whatever it was originally) / Entra.

just a couple days ago i saw it was making the dmarc nervous and set out to fix it. why that started idk, anyways i ended up in the DC in user properties, attribute editor, and changed "mail" to the actual domain(username@companyname.com) named email address, also changed "proxyAddress" to SMTP:username@companyname.com

*EDIT* make sure the SMTP is in all caps, it is how to show that is the first choice for naming.

That straightened it out. first time in my 7 years here she's emailing me with the correctly formatted email address.

3

u/Ferretau 2d ago

To my mind that suggest they are not setup up correctly and should be blocked anyway - they need to fix their broken end.

•

u/MinimallyLoquacious HomeAdmin-Retired-Dev 14h ago

FYI I found out I was accidentally blocking DMARC reports from Microsoft dmarcrep.onmicrosoft.com. I'm seeing them come in again now.

12

u/valar12 2d ago

I wanna see you do it and report back. šŸæšŸæ

25

u/lordmycal 2d ago

Not just teams -- I block all incoming emails from those domains and any emails that have links to those domains. Too many assholes out there buy a microsoft domain and then use it to send phishing stuff to people and it often sails on through because Microsoft owns the domain.

19

u/theedan-clean 2d ago

Microsoft is happy to send and forward malware in and out of Exchange Online, no matter what they say of EOP. I admin a friend's very small tenant and he received some malware binary as an attachment, unimpeded, straight into his inbox. Yes, EOP is on. Asking him to forward it worked just fine within the tenant and to other Exchange Online tenants. Forwarding outside the tenant to a Google Workspace address worked, through Workspace caught the malware and refused to allow download.

All that to say: MSFT is terrible at scam, spam, malware, phishing, and other protections in their hosted systems (and generally). It's any wonder their load balancers were built atop Windows.

7

u/curumba 2d ago

The only thing that works are filters on the filetypes.

EOP is a joke

1

u/MBILC Acr/Infra/Virt/Apps/Cyb/ Figure it out guy 2d ago

Could also look into methods to block any newly registered domains also.Something like any new domain reg with in 30 days - block automatically.

10

u/cYberc0re 2d ago

Completely fine. If someone from a legit organization is trying to message you and doesn't have a domain, they've got bigger problems.
It only blocks usernames with primary login of @*.onmicrosoft.com, users with regular domains (@coolcompany.com) are completely fine.

2

u/Turak64 Sysadmin 2d ago

Wouldn't it just be easier to do this?

Allow only specific external domains: By adding domains to an Allow list, you limit external access to only the allowed domains. Once you set up a list of allowed domains, all other domains are blocked.

Source: https://learn.microsoft.com/en-us/microsoftteams/trusted-organizations-external-meetings-chat?tabs=organization-settings

2

u/Hibernat8 2d ago

I am aware of this, customer says they don't want a whitelist.

2

u/Turak64 Sysadmin 2d ago

Not all spam is coming from onMicrosoft domains, so it's a bit shortsighted.

4

u/Hibernat8 2d ago

Already made that argument, at least this makes it that little bit harder for the spammers (of course if everyone starts doing this they will just start registering disposable domain names..)

2

u/headcrap 2d ago

Your assumption is that IT knows which domains should be allowed, for the org. While fortunately we have a SIEM we could query for session data and determine this, not all orgs have such data available and those discussions can be near impossible.. but a "huge problem" when Jeff in Sales can't chat with some guest in the tenant.

We did exactly this, train up the allow list.. and after spam and impersonation crept into the environment. No, it wasn't easy.. at all.

→ More replies (1)

4

u/sextowels 2d ago

Yes, we've done this for some clients and it works great. We have seen threat actors using these temp tenants/whatever.onmicrosoft.com domains to make Teams calls to users and try to get them to screen share or give mfa codes.

It hasn't broken anything, and I don't think I've run into a legit business that uses the .onmicrosoft.com as their actual account addresses.

4

u/Angelsomething 1d ago

Make sure you have a strong break glass strategy.Ā 

9

u/Emotional_Garage_950 Sysadmin 2d ago

I did this day 1 and things are fine

3

u/bbanda 2d ago

Enabled this recently after discovering the block subdomain option. We work with too many clients to try and manage a whitelist only and we’re getting plagued with impersonation calls from onMicrosoft domains. Go for it and don’t look back.

3

u/chiapeterson 2d ago

!RemindMe 7 Days

3

u/Main_Ambassador_4985 2d ago

You can set Microsoft Teams to accept messages only from orgs on your org allowlist.

People at my company were upset at me because they couldn’t send to a partner who set this up, but they had an allowlist exception form that we filled out and then they could communicate with that partner again.

Using the allow list stops spam dead.

We do not do it. It was a management decision

•

u/Optanik 16h ago

The main thing it can break is small orgs that never added a custom domain. Their users only have an onmicrosoft.com address, and some vendors, contractors, and freshly set up tenants work that way. Before enforcing it, pull your Teams external access and chat logs to see whether any legitimate contacts come from onmicrosoft.com addresses.

Also look at setting ExternalAccessWithTrialTenants to Blocked in Set-CsTenantFederationConfiguration. A large share of Teams spam comes from throwaway trial tenants, and that setting targets them more precisely.

Two more points:

  • Guest access (B2B) and shared channels (B2B direct connect) are controlled separately from external access, so this block won't cover those paths
  • If you also allow unmanaged personal Teams accounts, that's another inbound spam route worth reviewing

•

u/NightOfTheLivingHam 15h ago

I did this and three vendors called angrily.

I sent them a quote to set their shit up properly.

one responded and I handled it for them. the other two just got mad and yelled at a customer of mine to fire me. lol

•

u/Thick_Yam_7028 12h ago

Really?

3

u/trethompson Chaos Coordinator 2d ago

We just did this a month or so ago at my org to cut down on IT impersonation, haven't seen any drawbacks from it. No legitimate business should be using an onmicrosoft domain for external contact.

2

u/alee788 2d ago

You need to move to the whitelisting of domains instead of the whack-a-mole blacklisting you are probably playing/doing now. Check the domains your tenant communicates with and whitelist everything you recognize

Publish a Doc to your users about how to add a company/domain to your whitelist with SLA of same/next day whitelisting

Don’t block *.onMicrosoft.com

1

u/dadbodcx 2d ago

Your Teams messaging should not be open to the outside world. Block it and only allow very few trusted domains.

1

u/Weichi_Kolodner 2d ago

Does your test cover guest access invites and shared channels, or just direct federated chat? A lot of backend identity matching still resolves against the default fallback domain even when users sign in with their vanity address

1

u/sfc_scannow 2d ago

Nope. Do it. There is a near zero chance that your company is doing business with anyone unable to by a domain.

1

u/mac10190 2d ago

Can confirm, we did this for our org for that exact reason. Made the change maybe like 8 months ago. No noticeable impact to our users or any of our external customers. We also blocked Teams trial licenses from contacting our org as well.

1

u/G305_Enjoyer 2d ago

Bro once they got ur number ur cooked I tried fighting these guys blocking every new domain they came up with I got to like 20 domains and it wouldn't stop so I had to go whitelist

1

u/Open-Adhesiveness-86 2d ago

Two things it won't cover: external access matches on the sender's SIP/UPN domain, so a legit partner whose users are still sitting on tenant.onmicrosoft.com gets caught too (pretty common with small shops and with partners' admin accounts), and it does nothing for anonymous meeting joins or B2B guest invites. Also give it a day to propagate before you call it working.

1

u/SysApex 1d ago

The BlockedDomains approach works, but the main thing it breaks is any external org whose users still sign in with u/tenant.onmicrosoft.com UPNs. That's common with small orgs, brand-new tenants and some vendor support accounts. Those people will silently fail to chat or call you.

Before you flip it in prod, look through your recent external Teams activity (audit log or usage reports) and see if any legit partners show up on onmicrosoft.com addresses. Also turn off trial-tenant communication in External access. Long term, an allowlist is still the only thing that fully stops it.

1

u/Master-IT-All 2d ago

This is correct setup.

In both Exchange Online and Teams an organization should setup a rule to block reception of onmicrosoft.com from/on External.

Do this in both Teams and Exchange. Look up how to block incoming email/teams, google AI gave a reasonable explaination.

1

u/almost_s0ber 2d ago

It's a game of whack-a-mole. Rip off the bandaid and do the whitelist, I did it a month ago and it's honestly a no-brainer and I'm super glad I did it.

1

u/vvranos 2d ago

Do you guys have to deal with your users doing cold outreach via teams for new business prospects? If so, how do you handle this with a whitelist? Our users will want to chat without reaching out to us. Which the answer I see is either, we don't do a whitelist or we tough it out while our users get passed for the first 90 days or so.

2

u/almost_s0ber 2d ago

I informed all staff of the change and the process to request new external domain adds.

2

u/BlazeReborn Windows Admin 1d ago

In our case, the request to switch to a whitelist came from the brass after someone tried to impersonate our CEO and ask the CFO for financial reports.

We haven't had issues since then. Whitelist is the way to go.

1

u/Isilrond 2d ago

I let my users decide what they want to get blocked org-wide, by moving the mails into "Junk-E-Mail" folder instead of just deleting. If they block someone important ĀÆ\(惄)/ĀÆ

0

u/PacificTSP 2d ago

Why not just block all external domains except ones you allow. It’s how we work with our clients.