Skip to main content

159 posts tagged with "Security"

Security Practices and Solutions

View All Tags

How to Accept Activities Only from Your Tenant in the Microsoft 365 Agents SDK in C#

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

A bot registered for Teams can usually be installed by people in any organization. If yours is meant for your own organization only, check the tenant ID of every incoming activity, and drop the ones from anywhere else before your agent sees them. A small middleware in the Microsoft 365 Agents SDK does that in one place.

How to Turn On the Outbound Host Validator in the Microsoft 365 Agents SDK in C#

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

Every activity tells your agent where to send its reply, in its serviceUrl, and by default the Microsoft 365 Agents SDK sends the reply wherever that says. The outbound host validator limits replies to Microsoft's own hosts and the ones you list. It's off until you turn it on, with two settings in appsettings.json.

Fixed: "ServiceUrl host is not in the configured allowed hosts" for localhost in the Microsoft 365 Agents SDK

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

I turned on the Microsoft 365 Agents SDK's outbound host validator and tested my agent locally. Every local message came back 400, and the agent logged ServiceUrl host is not in the configured allowed hosts. ServiceUrl='http://localhost:5299/'. I added localhost to the allowed hosts, and the next request still got 400. The host wasn't the problem: localhost is a loopback address, and the validator refuses those until you allow private network addresses.