R – What risk does Reflection pose? (Medium Trust)

asp.nethostingmedium-trustreflectionSecurity

The lack of reflection in Medium Trust hosting environments seems to cause a lot of problems for many popular web applications.

  • Why is ReflectionPermission disabled by default with Medium Trust?
  • What risk does reflection pose in a shared hosting environment?

For random reference, see MSDN: How to use Medium Trust in ASP.NET 2.0

Best Answer

Reflection allows malicious code to inspect all kinds of secrets: not so much intellectual property (though sure, that too), but data that should be private and secure, like connection strings, passwords, bank account data, etc..

Of course, many programs expose this data as a matter of course through even more-easily compromised vectors, but there's no reason to increase an application's attack surface.

Edited to bring some of the conversation up from the comments:

It's probably true that the real risk is unrestricted file system access, which is what turns reflection into a real danger. If a bad actor can get an assembly (or something that gets compiled into an assembly) into your virtual directory, you're in trouble if they have reflection permission. (Of course if this happens, there are other potential problems as well, but that shouldn't discount this particular vulnerability.)

In a shared hosting environment that's just harder to prevent, though it certainly isn't impossible. Perhaps it's worth cross-posting this question to ServerFault to see what the good folks there have to say.

Related Topic