See for example the Enterprise Source Licensing Program page
https://www.microsoft.com/en-us/sharedsource/enterprise-sour...Allowed purposes for said licensing program includes “performing internal security audits of the Microsoft Windows operating system”.