We have a scripting engine that allows our customers to make web requests from inside of a .NET App Domain. Penetration testers pointed out that our scripting engine allows customers to make web requests against the AWS Metadata URL (http://169.254.169.254/latest/meta-data) which we need to prevent. I know how to create a whitelist of URLs using code that looks like:
Dim perm As New System.Net.WebPermission(PermissionState.None)
Dim metadataUrl As New Regex("http://169\.254\.169\.254/.*")
perm.AddPermission(Net.NetworkAccess.Connect, metadataUrl)
But I want to create a blacklist with only the AWS Metadata URL. I know that for security purposes, blacklists are generally frowned upon, but more and more of our customers are using Restful API's, and we can't release a new code version every time a customer wants to talk with some new service. How can I do this? Is there a Regex pattern that will match every URL except those that match the string above?