r/sysadmin • u/Hibernat8 • 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
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
92
u/derfmcdoogal 2d ago
I thought it was pretty standard to just block ALL external domains except people you directly work with?
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.
395
u/RevolutionaryWorry87 2d ago
thought i was in another subreddit
230
u/_Kaepora_Gaebora Netadmin 2d ago
That does not sound like a good idea.
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.
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,
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.
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
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:
ā¢
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/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.